Skip to content

Commit

Permalink
rename functions in scripts and add docs, according to #99
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahAlidoost committed Sep 12, 2023
1 parent b08bdff commit 23bfcae
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 17 deletions.
6 changes: 5 additions & 1 deletion src/+dryair/assembleCoefficientMatrices.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
function [RHS, AirMatrices, SAVE] = Air_EQ(AirMatrices, Delt_t, P_g)
function [RHS, AirMatrices, SAVE] = assembleCoefficientMatrices(AirMatrices, Delt_t, P_g)
%{
Assemble the coefficient matrices of Equation 4.32 STEMMUS Technical
Notes, page 44, for dry air equation.
%}

C1 = AirMatrices.C1
C2 = AirMatrices.C2
Expand Down
6 changes: 5 additions & 1 deletion src/+dryair/calculateBoundaryConditions.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
function [RHS, AirMatrices] = Air_BC(BoundaryCondition, AirMatrices, ForcingData, RHS, KT)
function [RHS, AirMatrices] = calculateBoundaryConditions(BoundaryCondition, AirMatrices, ForcingData, RHS, KT)
%{
Determine the boundary condition for solving the dry air equation.
%}

TopPg = 100 .* (ForcingData.Pg_msr);
ModelSettings = io.getModelSettings();
n = ModelSettings.NN;

% Apply the bottom boundary condition called for by NBCPB
if BoundaryCondition.NBCPB == 1 % Bounded bottom with the water table
RHS(1) = BtmPg;
Expand Down
9 changes: 6 additions & 3 deletions src/+dryair/calculateDryAirParameters.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
function AirVariabes = AirPARM(SoilVariables, GasDispersivity, TransportCoefficient, InitialValues, GasDispersivity,...
P_gg, Xah, XaT, Xaa, RHODA)

function AirVariabes = calculateDryAirParameters(SoilVariables, GasDispersivity, TransportCoefficient, InitialValues, GasDispersivity,...
P_gg, Xah, XaT, Xaa, RHODA)
%{
Calculate all the parameters related to dry air equation e.g., Equation
3.59-3.64, STEMMUS Technical Notes, page 27-28.
%}
ModelSettings = io.getModelSettings();
Constants = io.define_constants();

Expand Down
7 changes: 6 additions & 1 deletion src/+dryair/calculateMatricCoefficients.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
function AirMatrices = Air_MAT(AirVariabes, InitialValues)
function AirMatrices = calculateMatricCoefficients(AirVariabes, InitialValues)
%{
Calculate 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 for dry air equation.
%}

AirMatrices.C1 = InitialValues.C1;
AirMatrices.C2 = InitialValues.C2;
Expand Down
23 changes: 14 additions & 9 deletions src/+dryair/solveDryAirEquations.m
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
function [RHS, SAVE, P_gg] = Air_sub(SoilVariables, GasDispersivity, TransportCoefficient, InitialValues, GasDispersivity,...
BoundaryCondition, P_gg, Xah, XaT, Xaa, RHODA, KT, Delt_t)
function [RHS, SAVE, P_gg] = solveDryAirEquations(SoilVariables, GasDispersivity, TransportCoefficient, InitialValues, GasDispersivity,...
BoundaryCondition, P_gg, Xah, XaT, Xaa, RHODA, KT, Delt_t)
%{
Solve the dry air equation with the Thomas algorithm to update the soil
air pressure 'P_gg', the finite difference time-stepping scheme is
exampled as for the soil moisture equation, which derived in 'STEMMUS
Technical Notes' section 4, Equation 4.32.
%}
AirVariabes = dryair.calculateDryAirParameters(SoilVariables, GasDispersivity, TransportCoefficient, InitialValues, GasDispersivity,...
P_gg, Xah, XaT, Xaa, RHODA);

AirVariabes = AirPARM(SoilVariables, GasDispersivity, TransportCoefficient, InitialValues, GasDispersivity,...
P_gg, Xah, XaT, Xaa, RHODA);
AirMatrices = dryair.calculateMatricCoefficients(AirVariabes, InitialValues);

AirMatrices = Air_MAT(AirVariabes, InitialValues);
[RHS, AirMatrices, SAVE] = dryair.assembleCoefficientMatrices(AirMatrices, Delt_t, P_g);

[RHS, AirMatrices, SAVE] = Air_EQ(AirMatrices, Delt_t, P_g);
[RHS, AirMatrices] = dryair.calculateBoundaryConditions(BoundaryCondition, AirMatrices, ForcingData, RHS, KT);

[RHS, AirMatrices] = Air_BC(BoundaryCondition, AirMatrices, ForcingData, RHS, KT);

[AirMatrices, P_gg, RHS] = Air_Solve(RHS, AirMatrices);
[AirMatrices, P_gg, RHS] = dryair.solveTridiagonalMatrixEquations(RHS, AirMatrices);
6 changes: 5 additions & 1 deletion src/+dryair/solveTridiagonalMatrixEquations.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
function [AirMatrices, P_gg, RHS] = Air_Solve(RHS, AirMatrices)
function [AirMatrices, P_gg, RHS] = solveTridiagonalMatrixEquations(RHS, AirMatrices)
%{
Use Thomas algorithm to solve the tridiagonal matrix equations, which is
in the form of Equation 4.25 STEMMUS Technical Notes, page 41.
%}

ModelSettings = io.getModelSettings();
RHS(1) = RHS(1) / AirMatrices.C6(1, 1);
Expand Down
3 changes: 2 additions & 1 deletion src/STEMMUS_SCOPE.m
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,8 @@
end

if Soilairefc == 1
run Air_sub;
[RHS, SAVE, P_gg] = dryair.solveDryAirEquations(SoilVariables, GasDispersivity, TransportCoefficient, InitialValues, GasDispersivity,...
BoundaryCondition, P_gg, Xah, XaT, Xaa, RHODA, KT, Delt_t);
end

if Thmrlefc == 1
Expand Down

0 comments on commit 23bfcae

Please sign in to comment.