Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The differences in two_nodes between R and Python #143

Closed
TwinGan opened this issue Nov 5, 2024 · 4 comments
Closed

The differences in two_nodes between R and Python #143

TwinGan opened this issue Nov 5, 2024 · 4 comments
Milestone

Comments

@TwinGan
Copy link
Contributor

TwinGan commented Nov 5, 2024

Differences caused by additional code logic unique to Python

  1. First
    At the end of the loop, Py package will reassign the two variables e_skin , m_rsw ( regsw in R)
    When w > w_max, the e_rsw will be assign to prsw * emax which will make m_rsw become different because the reassign logic.
        if w > w_max:
            w = w_max
            p_rsw = w_max / 0.94
            e_rsw = p_rsw * e_max
            e_diff = 0.06 * (1.0 - p_rsw) * e_max
        if e_max < 0:
            e_diff = 0
            e_rsw = 0
            w = w_max
        e_skin = (
            e_rsw + e_diff
        )  # total evaporative heat loss sweating and vapor diffusion
        m_rsw = (
            e_rsw / 0.68
        )  # back calculating the mass of regulatory sweating as a function of e_rsw

In the R package, there was no this logic.

The extra logic

  1. Second
    For input:
    calc2Node(ta = 45,tr = 45,vel = 1.1,rh = 20,clo = 0.2,met = 3) in R
    two_nodes(tdb = 45,tr = 45,v = 1.1,rh = 20,clo = 0.2,met = 3) in Python

The R code result will lead Python's result by one loop
It 's the result of m_rsw(regsw) in the end of each loop (I have added the following extra logic to R)

image
image

You can see that the 59 loop m_rsw in R equals the 60 loop in Python.
I am sure that these two loop all start from 1
image
image

I don't understand why but this situation happened.

  1. Could we increase the tolerance of W.
    Expected w = 0.2 Actual w = 0.226183272947463
    Expected w = 0.2 Actual w = 0.174338146533957
    Expected w = 0.1 Actual w = 0.127748749502237
    All three cases failed because of the tolerance value.

@FedericoTartarini and @marcelschweiker what shall I do with those differences?

@marcelschweiker
Copy link
Collaborator

@TwinGan and @FedericoTartarini If I interprete correctly, we can fix the difference either by making an addition to R or removing the addition in py. I am fine with both and suggest we go for the version, that is closer to the reference values.
@FedericoTartarini What was the source again for the reference values for 2-node model?

@FedericoTartarini
Copy link
Collaborator

@TwinGan and @marcelschweiker please find below my comments.

First point

The code from Gagge is

image

The two-node code from Mark Fountain is as follows.

image

I have also attached both documents for your reference. Please let me know what do you think.

Gagge et al_1986_A standard predictive index of human reponse to the thermal environemnt.pdf

Fountain_A derivation of the Gagge 2-node model.pdf

Second point

I am not sure why this is happening. It must be something related to how we initialise the simulation. One must be skipping the first run.

Third point

I think there is an issue in pythermalcomfort and we need to return w with more decimals, I think I have already partially fixed this in the new version of pythermalcomfort. I should not be returning w with only one dwecimal value. Please have a look at the code in development. If the code is not there yet I will fix it as soon as I have time.

@FedericoTartarini
Copy link
Collaborator

@TwinGan, Marcel and I looked into the code and we have noticed that the code is actually the same. The difference you mentioned in point 1 is not there. However, we identified an issue caused by the iteration and this is what it is causing the error.

I will fix point 2 and 3 in the new version of pythermalcomfort.

@FedericoTartarini FedericoTartarini added this to the v3 milestone Dec 18, 2024
@FedericoTartarini
Copy link
Collaborator

I am closing this issue since I solved point 2 and 3 and I opened issue #147 for point 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants