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

Bringing in snowing #43

Draft
wants to merge 49 commits into
base: develop
Choose a base branch
from
Draft

Bringing in snowing #43

wants to merge 49 commits into from

Conversation

bizzinho
Copy link
Member

@bizzinho bizzinho commented Jul 4, 2023

No description provided.

ltdeck and others added 14 commits June 26, 2022 15:03
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
@bizzinho bizzinho added the enhancement New feature or request label Jul 4, 2023
Copy link
Member Author

@bizzinho bizzinho left a 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
Copy link
Member Author

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?

Copy link
Member Author

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

Copy link
Collaborator

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
Copy link
Member Author

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?

Copy link
Collaborator

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
Copy link
Member Author

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?

Copy link
Collaborator

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
Copy link
Member Author

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?

Copy link
Collaborator

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


from collections.abc import Mapping

from typing import Optional, List, Any

from .__init__ import __citation__, __bibtex__
Copy link
Member Author

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 :)

Copy link
Collaborator

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
Copy link
Member Author

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?

Copy link
Member Author

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

Copy link
Collaborator

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.

)
)

# set up additional parameters for VISF
Copy link
Member Author

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, changed.

constVars.extend(["lambda_air", "air_gap"])

if config["temperature"] != "homogeneous":
if config["vial"]["geometry"]["shape"] != "cylinder":
Copy link
Member Author

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


elif config["vial"]["geometry"]["shape"].startswith("cyl"):
geoKeys = config["vial"]["geometry"].keys()
if ("radius" in geoKeys) and (config["vial"]["geometry"]["radius"] is not None):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit tests

k_f = float(config["solution"]["k_f"])
M_s = float(config["solution"]["M_s"])

# heat conductivity
Copy link
Member Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected.

Copy link
Member Author

@bizzinho bizzinho left a 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

config["vial"]["geometry"]["width"]
)

elif config["vial"]["geometry"]["shape"].startswith("cyl"):
Copy link
Member Author

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?

Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Member Author

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?

Copy link
Collaborator

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):
Copy link
Member Author

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

Copy link
Collaborator

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):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Collaborator

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_liquid(T_liq):
"""_summary_
Copy link
Member Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filled out.

raise NotImplementedError(
(
f'Configuration "{self.configuration}" '
+ "not correctly specified, use shelf, jacket or VISF."
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check in constants

Copy link
Collaborator

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?

Copy link
Collaborator

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.

k: dict = {"int": 0, "ext": 0, "s0": 50, "s_sigma_rel": 0},
opcond: OperatingConditions = OperatingConditions(),
temperature: str = "spatial_1D",
configuration: str = "shelf",
Copy link
Member Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator

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
Copy link
Member Author

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

Copy link
Collaborator

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

return self._simulationStatus

@property
def getTime(self) -> np.ndarray:
Copy link
Member Author

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"

Copy link
Member Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, changed.

return self._time

else:
raise AssertionError("Simulation not yet carried out or completed.")
Copy link
Member Author

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"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks. Adapted

@bizzinho bizzinho requested a review from ltdeck July 4, 2023 15:28
@bizzinho bizzinho marked this pull request as draft July 5, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants