-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bringing in snowing #43
base: develop
Are you sure you want to change the base?
Conversation
Model for spatial evolution within a single vial. Developed by Andraz Kosir, as part of his M.Sc. thesis project.
Revised language of new part on v 2.0
Also updated the general part at the beginning
Added description for V2.0
Added Andraz
updated pallet article from pre-print to final version
updated for v2.0
updated for version 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review is still WIP. In particular, snowing.py
, utils.py
, and single_vial_spatial_model.py
have not been reviewed yet. Still, I think the first comments can be of use / allow you to get started.
The main comment are
- there are no new unit tests, which is a gap.
- the purpose of
sample.py
is unclear - I am not convinced that this has been "regression tested", i.e., made sure that the existing functionalities work as expected by the user/explained in the tutorial
shape: cube | ||
# length [m] | ||
# base shape of vial (in the spatial version only cylinder is accepted) | ||
shape: cylinder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this change to the default break snow and snowfall?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It at least breaks the associated unit test
FAILED tests/test_constants.py::test_warningWrongYamlSchema - assert 7.853981633974483e-07 == ((1 * 0.01) * 0.01)
This is due to the fact that the expectation was that the default shape is a cube
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot really generalize the shape for all models, so my idea was that we keep cube as the default shape for snow and snowfall, but we change it to cylinder for snowing. Then the users have to change this depending on which model they want to use.
sample.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this file? Can this be integrated into the tutorial?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it could be integrated into the tutorial. So far it was actually just for me for quickly running different model dimensionalities while testing the changes. Forgot to remove it
solution: | ||
# kg/m^3 density of water / assumed constant for all phases | ||
# solute mass fraction [-] | ||
solid_fraction: 0.25 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this change/increase affect snow and snowfall?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, default should stay 0.05. I changed it back.
# °C equilibrium freezing temperature pure water | ||
T_eq: 0 | ||
# initial temperature of the solution | ||
T_init: 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have removed T_init without replacement, does this not break snow and snowfall?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I checked everything, T_init is not used anywhere since the pallet update (it's commented out in snowflake
src/ethz_snow/constants.py
Outdated
|
||
from collections.abc import Mapping | ||
|
||
from typing import Optional, List, Any | ||
|
||
from .__init__ import __citation__, __bibtex__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't remove stuff unless you are sure that this is what you want :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know what happened here, accidentally I guess, I put it back now.
@@ -1,36 +1,87 @@ | |||
# temperature resolution within vial (homogeneous, spatial_1D, spatial_2D) | |||
temperature: spatial_2D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that this is not a informative name for this key. How about temp_model
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or temp_dim
or dimensionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fully agree, changed to dimensionality.
src/ethz_snow/constants.py
Outdated
) | ||
) | ||
|
||
# set up additional parameters for VISF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this comment should read "jacket", not VISF?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, changed.
src/ethz_snow/constants.py
Outdated
constVars.extend(["lambda_air", "air_gap"]) | ||
|
||
if config["temperature"] != "homogeneous": | ||
if config["vial"]["geometry"]["shape"] != "cylinder": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be unit tested
src/ethz_snow/constants.py
Outdated
|
||
elif config["vial"]["geometry"]["shape"].startswith("cyl"): | ||
geoKeys = config["vial"]["geometry"].keys() | ||
if ("radius" in geoKeys) and (config["vial"]["geometry"]["radius"] is not None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit tests
src/ethz_snow/constants.py
Outdated
k_f = float(config["solution"]["k_f"]) | ||
M_s = float(config["solution"]["M_s"]) | ||
|
||
# heat conductivity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confusing/contradicting comments above and below line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
44 fix pipeline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuing my review.. I believe there are now quite a few comments. Maybe I make a pause here and let you react before I continue with the meat of snowing
src/ethz_snow/constants.py
Outdated
config["vial"]["geometry"]["width"] | ||
) | ||
|
||
elif config["vial"]["geometry"]["shape"].startswith("cyl"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but if the vial geometry is cylinder, then it has to be a single vial simulation, right? There is no implementation of the intervial heat fluxes for cylinders, is there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm right, there should be a check for this here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, if shape is cylinder then it is only a single vial spatial simulation. If cube, then it cannot be a spatial model as it is right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is not used in the package, was just used to make a piece of code, which generates a few plots used in a conference abstract public. Should be removed.
|
||
|
||
# vapour pressure estimation (temperature in K, pressure in Pa) | ||
def vapour_pressure_liquid(T_liq): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to have a source or ref for this state eq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
|
||
|
||
# vapour pressure estimation (temperature in K, pressure in Pa) | ||
def vapour_pressure_solid(T_sol): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
src/ethz_snow/utils.py
Outdated
|
||
# vapour pressure estimation (temperature in K, pressure in Pa) | ||
def vapour_pressure_liquid(T_liq): | ||
"""_summary_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a docstring skeleton, please fill it out @akosira
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filled out.
src/ethz_snow/snowing.py
Outdated
raise NotImplementedError( | ||
( | ||
f'Configuration "{self.configuration}" ' | ||
+ "not correctly specified, use shelf, jacket or VISF." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check in constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be checked here as well, if II allow passing configuration and model dimensionality as an inputs directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I now removed configuration, dimensionality as additional parameters to snowing. Everything is specified in configPath now. Only check is in constants.
src/ethz_snow/snowing.py
Outdated
k: dict = {"int": 0, "ext": 0, "s0": 50, "s_sigma_rel": 0}, | ||
opcond: OperatingConditions = OperatingConditions(), | ||
temperature: str = "spatial_1D", | ||
configuration: str = "shelf", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not yet convinced it makes sense to be able to provide configPath and temperature
and configuration
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of keeping temperature and configuration inputs was that once all the relevant constants are specified in the yaml file, the user could run the model for different configurations and thus with different dimensionalities without having to again modify the yaml file constantly. what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now removed configuration, dimensionality as additional parameters to snowing. Everything is specified in configPath now. I think you were right, this makes much more sense!
self._prop = None | ||
self._time = None | ||
self._shelf = None | ||
self._temp = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, it would be nice, albeit not critical, to use the same logic with a state variable X that includes both temp and ice, then make temp and ice properties that are derived from X
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but I would leave it like this actually. I find it more clear
src/ethz_snow/snowing.py
Outdated
return self._simulationStatus | ||
|
||
@property | ||
def getTime(self) -> np.ndarray: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, getTime
is a property and the @property
decorator defines this to be a getter function. A more natural name for this variable would be "time"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same holds true for all the other get...
properties, of course
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, changed.
src/ethz_snow/snowing.py
Outdated
return self._time | ||
|
||
else: | ||
raise AssertionError("Simulation not yet carried out or completed.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you really want to have this be an assertion error (which I think is fine), it's probably easier to just make the if condition an assert statement instead...
assert False, "This is False"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks. Adapted
Docstrings annotated
…r, warning is printed
Added spatial model article DOI
…to snowing-develop
No description provided.