SPL-ethz / snow

A Python package describing Stochastic Nucleation of Water in vials
https://spl-ethz.github.io/snow
MIT License
6 stars 1 forks source link

Variability in shelf-to-vial HT coefficient #13

Closed ltdeck closed 3 years ago

ltdeck commented 3 years ago
from ethz_snow.snowflake import Snowflake
d = {"int": 20, "ext": 20, "s0": 20, "s_sigma_rel": 0}
S = Snowflake(storeStates='all',N_vials=(7,7,1),k=d)
S.run()
S.k

When manually adjusting the heat transfer parameters, the effect on the 'shelf' parameters in k is unclear. Setting s_sigma_rel to 0 or to a value higher than 0.1 has no significant impact. Also, when increasing s0 to 2000, the absolute difference between s0 and the 'shelf' parameters remains the same, while it should increase since it is defined in relation to s0.

bug1 bug1a

ltdeck commented 3 years ago

bug1b

I think I found the problem. In line 813, the random term is just directly drawn from the normal distribution, but not multiplied with s_sigma_rel. However, I did not figure out yet why it still draws a random number even in case s_sigma_rel = 0.

bizzinho commented 3 years ago

Hey @ltdeck , problem is fixed.

It still drew a random number because the condition was only on "does this key exist in the dictionary?". There was no condition on the value. I implemented this now and also created a failsafe in case a k_shelf becomes smaller than 0 (non-physical).

ltdeck commented 3 years ago

There still seems to be an issue in case s_sigma_rel = 0, while it works fine for s_sigma_rel > 0, see the two attached screenshot sigma0 sigma01 s.

bizzinho commented 3 years ago

Unexpected behavior of 'any' created the issue.

any(False)
>>> TypeError: 'bool' object is not iterable

numpy.any behaves as expected

np.any(False)
>>> False

Fixed and created a unit test.

ltdeck commented 3 years ago

Again need to reopen this; the bug persists in snowfall. Setting s_sigma_rel to 0 leads to the attached error. It does work however, for snowflake.

Code:

from ethz_snow.snowfall import Snowfall
from ethz_snow.operatingConditions import OperatingConditions

d = {"int": 1, "ext": 1, "s0": 60, "s_sigma_rel": 0} 
S = Snowfall(k=d,Nrep=10,N_vials=(3,3,1),opcond=OperatingConditions(t_tot=1e4,cooling= {"rate": 1 / 60, "start": 20, "end": -50},holding= {"duration": 1, "temp": -12}) )

htbug_snowfall

bizzinho commented 3 years ago

Am not able to reproduce the issue. The code works for me. Are you sure you had loaded the updated module, @ltdeck ? Maybe restart the kernel and try again. If the problem does not occur, please close again.

ltdeck commented 3 years ago

Indeed, I was still working with the old kernel. Restarting solved the issue.