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

[GeoMechanicsApplication] Add micro climate condition #11890

Merged
merged 129 commits into from
Dec 15, 2023

Conversation

rfaasse
Copy link
Contributor

@rfaasse rfaasse commented Dec 14, 2023

📝 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).

avdg81 added 30 commits December 7, 2023 13:27
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.
Copy link
Contributor

@WPK4FEM WPK4FEM left a 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.

}

template <unsigned int TDim, unsigned int TNumNodes>
void TMicroClimateFluxCondition<TDim, TNumNodes>::CalculateAndAddRHS(
Copy link
Contributor

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.

Comment on lines 20 to 31
"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
},
Copy link
Contributor

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.

Copy link
Contributor Author

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": {
Copy link
Contributor

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.

Copy link
Contributor Author

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" : []
Copy link
Contributor

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.

Copy link
Contributor Author

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",
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@markelov208 markelov208 left a 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.

avdg81 and others added 5 commits December 14, 2023 14:56
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.
Copy link
Contributor Author

@rfaasse rfaasse left a 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.

avdg81 and others added 4 commits December 15, 2023 10:49
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.
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.
@avdg81 avdg81 enabled auto-merge (squash) December 15, 2023 13:58
Don't forget to specify the template arguments.
Copy link
Contributor

@WPK4FEM WPK4FEM left a 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;
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor

@markelov208 markelov208 left a 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 =
Copy link
Contributor

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?

@avdg81 avdg81 merged commit 327d0a7 into master Dec 15, 2023
16 of 17 checks passed
@avdg81 avdg81 deleted the geo/11866-add-micro-climate-condition branch December 15, 2023 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature GeoMechanics Issues related to the GeoMechanicsApplication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GeoMechanicsApplication] Define a new condition for micro-climate
4 participants