-
Notifications
You must be signed in to change notification settings - Fork 248
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
[GeoMechanicsApplication] Add micro climate condition #11890
Conversation
In order to compile, I had to make the following changes: - `T_condition.hpp` was renamed to `T_condition.h`. - Base class `TCondition` was renamed to `GeoTCondition`.
In the base class, `CalculateLocalSystem` is `public` as well, rather than `protected`. By making it `public`, it becomes easier to unit test the class.
In the base class, these member functions are `public` rather than `protected`. By making them `public`, it becomes easier to unit test the class. Added a first unit test that verifies no exception is thrown when a micro-climate condition is initialized.
The test checks whether calling `InitializeSolutionStep`, given a condition with dummy properties, does not throw an exception. The unit test for `Initialize` now also uses a 2-noded condition.
Copied the code from Mohamed's branch and made the following changes: - Renamed the conditions by prepending "Geo" to the original names. - Renamed the data members by adding "Geo" to their names.
Previously, in the test for `InitializeSolutionStep`, the micro-climate condition was created directly. It is, however, more convenient to let the model part take care of that.
By extracting several helper functions, the test body has become a lot more compact. Using this setup will make it easier to create similar tests for different condition configurations.
Test whether no errors occur when initializing the solution step.
Test whether no errors occur when initializing the solution step.
Test whether no errors occur when initializing the solution step.
Previously, all nodes were created on a line. This works for line conditions, but not for triangular or quadrilateral ones. With these changes we can now pass a function object that creates the nodes for us. The unit tests have been adapted such that they now use this mechanism.
To make the function that creates a micro-climate condition for testing more generally applicable, it now has a parameter for passing the dimension size. Also added a unit test to verify that when initializing the solution step of a micro-climate condition acting on a linear triangle executes without raising any errors.
The unit test verifies that when initializing the solution step of a micro-climate condition acting on a quadratic triangle executes without raising any errors. The helper function that creates the nodes for a triangle has been extended such that it can also create the mid-side nodes of a quadratic triangle.
The unit test verifies that when initializing the solution step of a micro-climate condition acting on a linear quadrilateral executes without raising any errors.
The unit test verifies that when initializing the solution step of a micro-climate condition acting on a serendipity element executes without raising any errors.
The unit test verifies that when initializing the solution step of a micro-climate condition acting on a LaGrange element executes without raising any errors.
The unit tests verify the left hand side matrix and the right hand side vector calculated for a line micro-climate condition with two nodes. To carry out the calculation, we also had to add solution step variables AIR_HUMIDITY, PRECIPITATION, and DT_TEMPERATURE.
Use a quadratic line condition rather than a linear one. The idea to is have a test for each shape of condition (i.e. line, triangle, and quadrilateral). At the same time, we would like to limit the tests to quadratic shape functions only (to avoid an explosion of tests).
Use a quadratic line condition rather than a linear one. The idea to is have a test for each shape of condition (i.e. line, triangle, and quadrilateral). At the same time, we would like to limit the tests to quadratic shape functions only (to avoid an explosion of tests).
Only quadratic shape functions are tested. To avoid repetition of test code, we now test both the LHS matrix and the RHS vector that have been calculated in the same unit test. As a result, two helper functions were no longer needed and they have been removed. Since we also need to compare a few computed zeros, we occasionally use an absolute tolerance rather than a relative one.
To avoid having a mix of `public` and `private` data members, as was found by SonarQube.
The `override` did exactly the same thing as the base class implementation.
Also removed two lines of commented out code.
- Removed some redundant blank lines. - Ensure there is a space between `//` and the actual comment. - Removed a redundant pair of parenthesis. - Removed some commented out code.
- Return the result using the return value rather than using an out argument. - Pass built-in types by value rather than by reference to const.
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.
Impressive testing!
The restructuring probably made clear that some more improvements can be made.
This implementation relies on input being in a precisely defined set of units that hardly can be checked with input verification. The redefinition of already existing material parameters is dangerous.
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
} | ||
|
||
template <unsigned int TDim, unsigned int TNumNodes> | ||
void TMicroClimateFluxCondition<TDim, TNumNodes>::CalculateAndAddRHS( |
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.
From the coding I read that these are the integration point contributions for a flux based and a temperature based part. The flux and the temperature are given as element DOF vectors, which I do not think change per integration point. Therefore I wonder if setting up elementmatrices fully and then doing the matrix vector multiplications once i.s.o. number of integration point times is more efficient.
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/python_scripts/geomechanics_solver.py
Outdated
Show resolved
Hide resolved
"THERMAL_CONDUCTIVITY_WATER" : 0.6, | ||
"LONGITUDINAL_DISPERSIVITY" : 0.0, | ||
"TRANSVERSE_DISPERSIVITY" : 0.0, | ||
"SOLID_COMPRESSIBILITY" : 1.0, | ||
"A1_COEFFICIENT" : 0.000000e+00, | ||
"A2_COEFFICIENT" : 0.000000e+00, | ||
"A3_COEFFICIENT" : 0.000000e+00, | ||
"ALPHA_COEFFICIENT" : 1.900000e-01, | ||
"QF_COEFFICIENT" : 0.000000e+00, | ||
"SMIN_COEFFICIENT" : 0.000000e+00, | ||
"SMAX_COEFFICIENT" : 4.800000e-04 | ||
}, |
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.
These are new and should now appear on our wiki.
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 to the documentation issue, we should add this to the wiki
} | ||
}] | ||
}, | ||
"processes": { |
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 processes for new variables deserve a place on our wiki.
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 to the documentation issue, we should add this to the wiki
"skin_output" : false, | ||
"plane_output" : [], | ||
"nodal_results" : ["TEMPERATURE"], | ||
"gauss_point_results" : [] |
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 have not seen HEAT_FLUX output yet. It would be a natural thing to have, like we also have fluid flux.
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 created a draft issue on our product backlog to do this
"process_name" : "ApplyScalarConstraintTableProcess", | ||
"Parameters" : { | ||
"model_part_name" : "PorousDomain.TopThermo", | ||
"variable_name" : "AIR_TEMPERATURE", |
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.
can we output and display these new variables? that would be a natural addition for model checking.
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 sure, I created a draft issue on our product backlog to check/implement this
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.
Richard, very well done. Just a couple of comments.
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_python/geo_mechanics_python_application.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/cpp_tests/test_T_micro_climate_flux_condition.cpp
Show resolved
Hide resolved
It is now part of the condition utilities. As a result, the newly introduced function `MakeVector` had become redundant, which has been removed now.
As a result, we no longer need the newly introduced function `MakeDiagonalMatrix`.
Eliminated a "raw" loop by selecting a more appropriate constructor.
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.
Only a few minor comments left when going through the code a last time.
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/micro_climate_constants.h
Show resolved
Hide resolved
applications/GeoMechanicsApplication/python_scripts/geomechanics_solver.py
Show resolved
Hide resolved
Parameters `LONGITUDINAL_DISPERSIVITY` and `TRANSVERSE_DISPERSIVITY` are not being used by the geomechanical code at all. Therefore, those have been removed from the new input files for integration testing.
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.h
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_conditions/T_microclimate_flux_condition.cpp
Outdated
Show resolved
Hide resolved
For some reason, in the previous implementation, each node was implicitly converted to the number 1 (WTF?). Now we use the `std::iota` algorithm to generate a sequence of local node indices and feed that to the `std::accumulate` algorithm.
It used to call the member function of an indirect base class. Now it calls the one from its direct base class.
…-climate-condition
Don't forget to specify the template arguments.
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 think it is good to do the remaining things after consultation with Mohamed. Lets go ahead merging the current status.
// Eq 5.31 | ||
const auto subsurface_heat_flux = | ||
NetRadiation - sensible_heat_flux_right - latent_heat_flux + | ||
mBuildEnvironmentRadiation - SurfaceHeatStorage; |
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.
misspelled? built environment
r_geom[NodeIndex].FastGetSolutionStepValue(AIR_TEMPERATURE); | ||
const auto absorbed_long_wave_radiation = | ||
EffectiveEmissivity * BoltzmannCoefficient * | ||
std::pow(atmospheric_temperature + 273.15, 4.0); |
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 273.15 shift from Celsius to Kelvin may deserve to be a named constant.
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.
Anne and Richard, great work. Just one comment on the variable name.
array_1d<double, TNumNodes>{row(r_N_container, integration_point_index)}; | ||
|
||
// Compute weighting coefficient for integration | ||
const auto IntegrationCoefficient = |
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.
should it be integration_coefficient?
📝 Description
This PR adds a new condition for microclimate, including effects like solar radiation, air temperature and wind speed. The new class is based on the work done by @johnvanesch @mnabideltares. This PR also adds test cases (both on an integration and unit level).