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

Refactor Enrgy_sub, move all Enrgy_ functions #100

Closed
5 tasks
BSchilperoort opened this issue Jul 29, 2022 · 14 comments · Fixed by #197
Closed
5 tasks

Refactor Enrgy_sub, move all Enrgy_ functions #100

BSchilperoort opened this issue Jul 29, 2022 · 14 comments · Fixed by #197
Labels
code enhancement New feature or request save model state Changes required to be able to save and load the model state.

Comments

@BSchilperoort
Copy link
Contributor

In STEMMUS_SCOPE.m, all Enrgy_ functions are called using the script Enrgy_sub:

run Enrgy_sub;

However, for model maintainability we want to remove all use of globals and running scripts.

Additionally, as all Enrgy_ functions seem to tackle one specific part of the model, these should be moved to a separate Matlab package with a appropriate name.


To do:

  • Move all Enrgy_ files to their own package, with an appropriate name
  • Convert Enrgy_sub into a function. Use structures to reduce the amount of input and output variables.
  • Add documentation to all functions
  • Make the required changes in the main file.
  • Create a pull request for the changes
@BSchilperoort BSchilperoort added code enhancement New feature or request save model state Changes required to be able to save and load the model state. labels Jul 29, 2022
@BSchilperoort BSchilperoort added this to the save/load model state milestone Jul 29, 2022
@yijianzeng
Copy link
Contributor

Thanks a lot, Bart, this would be great.

@SarahAlidoost
Copy link
Member

@yijianzeng For each function below, please add one line explanation and suggest a better name in this issue, thanks

  • Enrgy_sub
  • EnrgyPARM
  • Enrgy_MAT
  • Enrgy_EQ
  • Enrgy_BC
  • Enrgy_Solve
  • Enrgy_Bndry_Flux

@SarahAlidoost
Copy link
Member

@yijianzeng please help to answer the question above. thanks

@yijianzeng
Copy link
Contributor

  • Enrgy_sub

This function is to solve the Energy balance equation with the Thomas algorithm ('Air_solve') to update the soil temperature ('TT'), the finite difference time-stepping scheme is exampled as for the soil moisture equation, which is derived in 'STEMMUS Technical Notes' section 4, Equation 4.32.

@yijianzeng
Copy link
Contributor

  • EnrgyPARM

This function calculates all the parameters related to energy balance equation (e.g., Equation 3.65-3.73, STEMMUS Technical Notes, page 29-32).

@yijianzeng
Copy link
Contributor

  • Enrgy_MAT

This function calculates all the parameters related to matric coefficients (e.g., c1-c7) as in Equation 4.32 (STEMMUS Technical Notes, page 44, which is an example for soil moisture equation), but here it is for energy equation.

@yijianzeng
Copy link
Contributor

  • Enrgy_EQ

This function assembles the coefficient matrices of Equation 4.32 (STEMMUS Technical Notes, page 44, the example was only shown for the soil moisture equation), but here it is for the energy equation.

@yijianzeng
Copy link
Contributor

  • Enrgy_BC

This function determines the boundary condition for solving the energy equation.

@yijianzeng
Copy link
Contributor

  • Enrgy_Solve

This function uses Thomas algorithm to solve the tridiagonal matrix equations, which is in the form of Equation 4.25 (STEMMUS Technical Notes, page 41)

@yijianzeng
Copy link
Contributor

  • Enrgy_Bndry_Flux

This function calculates the energy fluxes on the boundary nodes.

@SarahAlidoost SarahAlidoost mentioned this issue Oct 2, 2023
9 tasks
@SarahAlidoost
Copy link
Member

SarahAlidoost commented Oct 3, 2023

While refactoring Enrgy_sub functions, I found two issues:

  1. The variables calculated in these lines are unused in the model.
  2. The function Enrgy_Bndry_Flux is used to calculate variables QET, QEB. However, they are unused in the model.
  3. DDhDZ is not defined as InitialValues!

@yijianzeng
Copy link
Contributor

  1. The variables calculated in these lines are unused in the model.

Hi Sarah, this is ok, these lines are calculated, and can be put into output when requested. They are corresponding to Equation 3.9, and 3.10 in the STEMMUS technical note.

@yijianzeng
Copy link
Contributor

2. The function Enrgy_Bndry_Flux is used to calculate variables QET, QEB. However, they are unused in the model.

The same, these are boundary fluxes calculated for any potential analysis, so could be deemed as model output and can be saved when requried.

@yijianzeng
Copy link
Contributor

3. DDhDZ is not defined as InitialValues!

hI Sarah, is this initialized here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code enhancement New feature or request save model state Changes required to be able to save and load the model state.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants