From 555cf2e4d23460ed45827f38f79f6f228e8f6c7c Mon Sep 17 00:00:00 2001 From: DanyangYu Date: Wed, 24 May 2023 15:45:14 +0200 Subject: [PATCH 1/5] fix issue #163 --- src/Root_properties.m | 59 ++++++++++++++++++------------------------- src/ebal.m | 2 +- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/Root_properties.m b/src/Root_properties.m index 27130beb..d2659866 100644 --- a/src/Root_properties.m +++ b/src/Root_properties.m @@ -3,43 +3,27 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% REFERENCES -function [Rl] = Root_properties(Rl, Ac, rroot, frac, bbx, KT) - %%% INPUTS - global DeltZ sfactor LAI_msr - % BR = 10:1:650; %% [gC /m^2 PFT] - % rroot = 0.5*1e-3 ; % 3.3*1e-4 ;%% [0.5-6 *10^-3] [m] root radius - %%% OUTPUTS - if KT < 2880 - fr = 0.3 * 3 * exp(-0.15 * LAI_msr(KT)) / (exp(-0.15 * LAI_msr(KT)) + 2 * sfactor); - if fr < 0.15 - fr = 0.15; - end - else - fr = 0.001; - end - % if KT<3840 - % fr=-0.091*LAI(KT)+0.40; - % else - % fr=0.001; - % end - % elseif KT<3200 - % fr=0.05; - % else - % fr=0.02; - % end +%{ + This function is used to calculate the dynamic growth of root + This part can refer to Wang et al. (2021) "Intergrated modelling of photosynthesis and transfer of energy, mass, and momentum in the SPAC system" +%} + +function [Rl] = Root_properties(Rl, Ac, rroot, frac, bbx, KT, DeltZ, sfactor, LAI_msr) +% %%% INPUTS +% global DeltZ sfactor LAI_msr + + fr = calculateRootfraction(KT); + DeltZ0 = DeltZ' / 100; BR = Ac * fr * 1800 * 12 / 1000000; root_den = 250 * 1000; %% [gDM / m^3] Root density Jackson et al., 1997 R_C = 0.488; %% [gC/gDM] Ratio Carbon-Dry Matter in root Jackson et al., 1997 nn = numel(Rl); + + % This is used to simulate the root growth if (~isnan(Ac)) || (Ac > 0) Rl = Rl .* DeltZ0; Delta_Rltot = BR / R_C / root_den / (pi * (rroot^2)); %% %% root length index [m root / m^2 PFT] - % for i=1:nn - % if Rl(i)>50000 - % frac(i)=0; - % end - % end if ~isnan(frac) frac = frac / sum(sum(frac)); else @@ -48,11 +32,18 @@ Delta_Rl = frac .* bbx * Delta_Rltot; Rl = Rl + Delta_Rl; Rl = Rl ./ DeltZ0; + end + +end + +function fr = calculateRootfraction(KT) + % this function is used to calculate the root fraction + if KT < 2880 %2880 means the time step when the root stops growing + fr = 0.3 * 3 * exp(-0.15 * LAI_msr(KT)) / (exp(-0.15 * LAI_msr(KT)) + 2 * sfactor); + if fr < 0.15 + fr = 0.15; + end else + fr = 0.001; end - % for i=1:nn - % if Rl(i)>50000 - % Rl(i)=50000; - % end - % end end diff --git a/src/ebal.m b/src/ebal.m index 76e07cd6..e1e5cf48 100644 --- a/src/ebal.m +++ b/src/ebal.m @@ -461,7 +461,7 @@ Rntot_PAR = LAI * (Fc * Rnh_PAR + equations.meanleaf(canopy, Rnu_PAR, 'angles_and_layers', Ps)); % net PAR leaves aPAR_Cab_eta = LAI * (Fc * (profiles.etah .* Rnh_PAR) + equations.meanleaf(canopy, profiles.etau .* Rnu_PAR, 'angles_and_layers', Ps)); % ... green ePAR * relative fluorescence emission efficiency - %%%%%%%%%%%%%%%%%%% [Delta_Rltot] = Root_properties(Actot,rroot); + %%%%%%%%%%%%%%%%%%% [Delta_Rltot] = Root_properties(Rl, Ac, rroot, frac, bbx, KT, DeltZ, sfactor, LAI_msr); %%%%%%%%%%%%%%%%%%% Delta_Rl = fc*Delta_Rltot; %%%%%%%%%%%%%%%%%%% Rl = Rl + Delta_Rl; %%%%%%%%%%%%%%%%%%% Rltot = sum(sum(Rl)); From fe41d5fcf5163291392a96ca8f01e2a2afafec93 Mon Sep 17 00:00:00 2001 From: DanyangYu Date: Wed, 24 May 2023 16:09:17 +0200 Subject: [PATCH 2/5] fix #163 writing style --- src/Root_properties.m | 11 +++++------ src/ebal.m | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Root_properties.m b/src/Root_properties.m index d2659866..2dbf3834 100644 --- a/src/Root_properties.m +++ b/src/Root_properties.m @@ -9,15 +9,15 @@ %} function [Rl] = Root_properties(Rl, Ac, rroot, frac, bbx, KT, DeltZ, sfactor, LAI_msr) -% %%% INPUTS -% global DeltZ sfactor LAI_msr + %INPUTS + %global DeltZ sfactor LAI_msr fr = calculateRootfraction(KT); DeltZ0 = DeltZ' / 100; BR = Ac * fr * 1800 * 12 / 1000000; - root_den = 250 * 1000; %% [gDM / m^3] Root density Jackson et al., 1997 - R_C = 0.488; %% [gC/gDM] Ratio Carbon-Dry Matter in root Jackson et al., 1997 + root_den = 250 * 1000; % [gDM / m^3] Root density Jackson et al., 1997 + R_C = 0.488; % [gC/gDM] Ratio Carbon-Dry Matter in root Jackson et al., 1997 nn = numel(Rl); % This is used to simulate the root growth @@ -33,12 +33,11 @@ Rl = Rl + Delta_Rl; Rl = Rl ./ DeltZ0; end - end function fr = calculateRootfraction(KT) % this function is used to calculate the root fraction - if KT < 2880 %2880 means the time step when the root stops growing + if KT < 2880 % 2880 means the time step when the root stops growing fr = 0.3 * 3 * exp(-0.15 * LAI_msr(KT)) / (exp(-0.15 * LAI_msr(KT)) + 2 * sfactor); if fr < 0.15 fr = 0.15; diff --git a/src/ebal.m b/src/ebal.m index e1e5cf48..eb0eb33c 100644 --- a/src/ebal.m +++ b/src/ebal.m @@ -461,11 +461,11 @@ Rntot_PAR = LAI * (Fc * Rnh_PAR + equations.meanleaf(canopy, Rnu_PAR, 'angles_and_layers', Ps)); % net PAR leaves aPAR_Cab_eta = LAI * (Fc * (profiles.etah .* Rnh_PAR) + equations.meanleaf(canopy, profiles.etau .* Rnu_PAR, 'angles_and_layers', Ps)); % ... green ePAR * relative fluorescence emission efficiency - %%%%%%%%%%%%%%%%%%% [Delta_Rltot] = Root_properties(Rl, Ac, rroot, frac, bbx, KT, DeltZ, sfactor, LAI_msr); - %%%%%%%%%%%%%%%%%%% Delta_Rl = fc*Delta_Rltot; - %%%%%%%%%%%%%%%%%%% Rl = Rl + Delta_Rl; - %%%%%%%%%%%%%%%%%%% Rltot = sum(sum(Rl)); - %%%%%%%%%%%%%%%%%%% fc = Rl./Rltot; + % [Delta_Rltot] = Root_properties(Rl, Ac, rroot, frac, bbx, KT, DeltZ, sfactor, LAI_msr); + % Delta_Rl = fc*Delta_Rltot; + % Rl = Rl + Delta_Rl; + % Rltot = sum(sum(Rl)); + % fc = Rl./Rltot; % sum of soil fluxes and average temperature % (note that averaging temperature is physically not correct...) Rnstot = Fs * Rns; % Net radiation soil From 4c51919af04e6e2a9606c123579e7fd0be6e2ee6 Mon Sep 17 00:00:00 2001 From: DanyangYu Date: Thu, 13 Jul 2023 11:01:56 +0200 Subject: [PATCH 3/5] fix issure # 163 add the notes of the function --- src/Root_properties.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Root_properties.m b/src/Root_properties.m index 2dbf3834..6a0ad3dd 100644 --- a/src/Root_properties.m +++ b/src/Root_properties.m @@ -6,12 +6,16 @@ %{ This function is used to calculate the dynamic growth of root This part can refer to Wang et al. (2021) "Intergrated modelling of photosynthesis and transfer of energy, mass, and momentum in the SPAC system" + Input: + Rl: root length index at last step + Ac: the net assimilation of canopy + rroot: radius of root + Output: + Rl: root length index at current step %} function [Rl] = Root_properties(Rl, Ac, rroot, frac, bbx, KT, DeltZ, sfactor, LAI_msr) - %INPUTS - %global DeltZ sfactor LAI_msr - + % calculate the fraction of root fr = calculateRootfraction(KT); DeltZ0 = DeltZ' / 100; From 9565fba635d7352d2537add1692cccd2429bae4c Mon Sep 17 00:00:00 2001 From: DanyangYu Date: Thu, 13 Jul 2023 11:21:33 +0200 Subject: [PATCH 4/5] solve the error of writing style --- src/Root_properties.m | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Root_properties.m b/src/Root_properties.m index 6a0ad3dd..712334d1 100644 --- a/src/Root_properties.m +++ b/src/Root_properties.m @@ -15,8 +15,15 @@ %} function [Rl] = Root_properties(Rl, Ac, rroot, frac, bbx, KT, DeltZ, sfactor, LAI_msr) - % calculate the fraction of root - fr = calculateRootfraction(KT); + % this function is used to calculate the root fraction + if KT < 2880 % 2880 means the time step when the root stops growing + fr = 0.3 * 3 * exp(-0.15 * LAI_msr(KT)) / (exp(-0.15 * LAI_msr(KT)) + 2 * sfactor); + if fr < 0.15 + fr = 0.15; + end + else + fr = 0.001; + end DeltZ0 = DeltZ' / 100; BR = Ac * fr * 1800 * 12 / 1000000; @@ -39,14 +46,3 @@ end end -function fr = calculateRootfraction(KT) - % this function is used to calculate the root fraction - if KT < 2880 % 2880 means the time step when the root stops growing - fr = 0.3 * 3 * exp(-0.15 * LAI_msr(KT)) / (exp(-0.15 * LAI_msr(KT)) + 2 * sfactor); - if fr < 0.15 - fr = 0.15; - end - else - fr = 0.001; - end -end From 1a38c55139d09afd9a57b0fc30ffd26b4b9d4c6b Mon Sep 17 00:00:00 2001 From: DanyangYu Date: Thu, 13 Jul 2023 11:30:50 +0200 Subject: [PATCH 5/5] solve the error of writing style2 --- src/Root_properties.m | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/Root_properties.m b/src/Root_properties.m index 712334d1..d8a56f5c 100644 --- a/src/Root_properties.m +++ b/src/Root_properties.m @@ -1,20 +1,16 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Subfunction - Root - Properties % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% REFERENCES -%{ - This function is used to calculate the dynamic growth of root - This part can refer to Wang et al. (2021) "Intergrated modelling of photosynthesis and transfer of energy, mass, and momentum in the SPAC system" - Input: - Rl: root length index at last step - Ac: the net assimilation of canopy - rroot: radius of root - Output: - Rl: root length index at current step -%} - function [Rl] = Root_properties(Rl, Ac, rroot, frac, bbx, KT, DeltZ, sfactor, LAI_msr) + %% REFERENCES + %{ + This function is used to calculate the dynamic growth of root + This part can refer to Wang et al. (2021) "Intergrated modelling of photosynthesis and transfer of energy, mass, and momentum in the SPAC system" + Input: + Rl: root length index at last step + Ac: the net assimilation of canopy + rroot: radius of root + Output: + Rl: root length index at current step + %} + % this function is used to calculate the root fraction if KT < 2880 % 2880 means the time step when the root stops growing fr = 0.3 * 3 * exp(-0.15 * LAI_msr(KT)) / (exp(-0.15 * LAI_msr(KT)) + 2 * sfactor);