Skip to content

Commit

Permalink
Merge branch 'C3-metabolic-and-leaf-model-tests' into C3-metabolic-an…
Browse files Browse the repository at this point in the history
…d-leaf-model-compare

Update tests for this branch
Fix bug in export_mod_dict where empty export_mod_enabled was interpreted incorrectly
Added test for exported variables
Move export functions into utils
Generalize the export functions to allow for use with other drivers
  • Loading branch information
langmm committed Dec 17, 2024
2 parents ae6cf2b + 3c37706 commit 67c9047
Show file tree
Hide file tree
Showing 64 changed files with 1,990 additions and 164 deletions.
28 changes: 28 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
* text=auto

*.fig binary
*.mat binary
*.mdl binary diff merge=mlAutoMerge
*.mdlp binary
*.mex* binary
*.mlapp binary
*.mldatx binary
*.mlproj binary
*.mlx binary
*.p binary
*.sfx binary
*.sldd binary
*.slreqx binary merge=mlAutoMerge
*.slmx binary merge=mlAutoMerge
*.sltx binary
*.slxc binary
*.slx binary merge=mlAutoMerge
*.slxp binary

## Other common binary file types
*.docx binary
*.exe binary
*.jpg binary
*.pdf binary
*.png binary
*.xlsx binary
23 changes: 23 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run tests
'on':
push:
branches-ignore:
- gh-pages
tags:
- '*'
schedule:
- cron: 0 10 * * 1
jobs:
build_cxx:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: true
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
- name: Run tests
uses: matlab-actions/run-tests@v2
with:
select-by-folder: tests
5 changes: 4 additions & 1 deletion BF_Rate.m
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,7 @@
global BF2TrDynaPSMB_vcet;
BF2TrDynaPSMB_vcet = vcet;

export_mod_dict("BF", BF_con, "");
global export_mod_enabled;
if export_mod_enabled == 1
export_mod_dict(t, "BF", BF_con, "");
end
7 changes: 0 additions & 7 deletions CM_Dict.m

This file was deleted.

11 changes: 11 additions & 0 deletions CM_Drive2.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@

suc = AssignVelocity(pop, currentPop);

global export_mod;
global export_mod_enabled;
export_mod = 'CM';
reenable_export_mod = export_mod_enabled;

[Tt,d] = ode15s(@CM_mb,[0,time],CMs, options1,PS_PR_Param, SUCS_Param);

global d_plot;
Expand All @@ -116,3 +121,9 @@
IModelCom;

CO2AR = TargetFunVal

if reenable_export_mod == 1
export_mod_enabled = 1;
[row,col]=size(d);
CM_mb(time, d(row, :), PS_PR_Param, Sucs_Param);
end
10 changes: 7 additions & 3 deletions CM_Rate.m
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,10 @@
CMr(40)= vpga_use ;% PGA utilisation in cytosol
CMr(41)= vatpf ;% ATP synthesis rate

export_mod_dict("PS", CM_Con, "Ps");
export_mod_dict("PR", CM_Con, "Pr");
export_mod_dict("SUCS", CM_Con, "");
global export_mod_enabled;
if export_mod_enabled == 1
export_mod_dict(t, "PS", CM_Con, "Ps", "", 1);
export_mod_dict(t, "PR", CM_Con, "Pr", "", 15);
export_mod_dict(t, "SUCS", CM_Con, "", "", 24);
export_mod_dict(t, "CM", CM_Con, "");
end
2 changes: 1 addition & 1 deletion CM_mb.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

% SUCS_Param(1) is unused
% global GLight;
% fini = cdn (t);
% fini = Condition(t);
% light = GLight;

% SUCS_Param(1) = light;
Expand Down
164 changes: 164 additions & 0 deletions Condition.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Copyright Xin-Guang Zhu, Yu Wang, Donald R. ORT and Stephen P. LONG
%CAS-MPG Partner Institute for Computational Biology, Shanghai Institutes for Biological Sciences, CAS, Shanghai,200031
%China Institute of Genomic Biology and Department of Plant Biology, Shanghai Institutes for Biological Sciences, CAS, Shanghai,200031
%University of Illinois at Urbana Champaign
%Global Change and Photosynthesis Research Unit, USDA/ARS, 1406 Institute of Genomic Biology, Urbana, IL 61801, USA.

% This file is part of e-photosynthesis.

% e-photosynthesis is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation;

% e-photosynthesis is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.

% You should have received a copy of the GNU General Public License (GPL)
% along with this program. If not, see <http://www.gnu.org/licenses/>.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Function [light] = condition; This function is used to store all the required
% environmental variables, such as light, CO2, O2, humidity as such. This function
% contains two parts. Part a includes the generic (default) conditions and the
% second part contains the detailed conditions for different time period.

function fini = Condition (t)
% Allow early abort if environmental inputs handled via ePhotosynthesis
% function
global dontCondition;
if (dontCondition)
global NumInter_draw;
NumInter_draw = 10;
fini = 1;
return;
end
global TestCa;
global TestLi;
global RUBISCOTOTAL;
global RUBISCOMETHOD; % The method for calculation of Rubisco catalyzed reaction
RUBISCOTOTAL = 3;
RUBISCOMETHOD = 2; % 1: Use enzyme concentration for calculation
% 2: Use the michaelis menton and enzyme together for calculation
global VolRatioStCyto
VolRatioStCyto =1;

global GP;
global gp2condition_RuCon;

if GP ==1
RUBISCOTOTAL = gp2condition_RuCon;
end


% First get the generic conditions

global CO2_cond;
global O2_cond;
global GLight;
global V16;
global Temp_cond;

global Cond_V16; % This variable is transfered from PSInitial for modificatin of V16, the rate of ATP synthesis.
% CO2Temp = TestCa*0.7;%280; % CO2 concentation % ppm
O2Temp = 0.21; % O2 concentration %default is 0.21, i.e. 21%.

% CO2_cond = CO2Temp /(3 * 10^4);
O2_cond = O2Temp*1.26;
% Temp_cond = 25;

light = 1000;
% light = TestLi*0.85*0.85; % light umol m-2 s-1

% Here the time dependent variable is regulated.
global tglobal;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Here define how many interval needed for the experiments %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NumberInterval = 10;

global NumInter_draw;
NumInter_draw = NumberInterval;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is an experimental protocol for doing repeatative experiment

Tinter = tglobal/NumberInterval;

FirstMet = 0;

% for index = 1:NumberInterval
% b = index * Tinter;
% if t <= b & FirstMet == 0
%
% modifier = 1 * index;
%
% global BF2XanCycle_pHl;
%
% global Xan2Stom_ABA;
%
%
% % Light regulation
% light = 100 * index;
% light = 2000;
%
% % CO2 regulation
% temp = 280;
% %temp = 1000-100 * (index-1);
%
% % O2 regualtion
% O2Temp = 0.21 ;
%
% CO2_cond = temp /(3 * 10 ^ 4);
% O2_cond = O2Temp*1.26;
%
% % Regulation of Vmax
% % Global RuACT_RC;
% % RuACT_RC(9) = 25 + 25 * index/2;
%
% FirstMet = 1;
%
% end
% end



% % % PAM MEASUREMENT
% if t < 20
% light = 7;
% else
% light=500;
% end
% % % PAM MEASUREMENT
% StepL = 20;
% if t<1
% light = 8000;
% elseif t>1 & t < 20
% light = 1;
% else
% index = floor(t/StepL);
% if t > (StepL*index) & t < (StepL*index+1)
% light = 8000;
% else
% light = 500;
% end
% end


% if t<200
% light = 1000;
% elseif t>200 & t<400
% light = 100;
% else
% light = 1000;
% end

GLight = light;
fini = 1;
14 changes: 0 additions & 14 deletions EPS_Dict.m

This file was deleted.

4 changes: 3 additions & 1 deletion EPS_Drive.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@
CO2A = zeros(5,1);


global export_mod;
global export_mod_enabled;
export_mod = 'EPS';
reenable_export_mod = export_mod_enabled;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -148,7 +150,7 @@
PhotosynthesisRate=Arate;

% Run again to output variables
if reenable_export_mod
if reenable_export_mod == 1
export_mod_enabled = 1;
EPS_mb(time, d(row, :), BF_Param, FI_Param, PS_PR_Param, Sucs_Param);
end
Expand Down
34 changes: 15 additions & 19 deletions EPS_mb.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,6 @@
CM_DYDT = CM_mb(t,CMs,PS_PR_Param, Sucs_Param);
FIBF_DYDT = FIBF_MB(t, FIBF_Con, BF_Param, FI_Param);

% Dump a copy of the model parameters if export_mod_enabled is set
global export_mod_enabled;
if (export_mod_enabled)
global export_mod_file_base;
if (t == 0)
dump_vars(export_mod_file_base + "init.txt", EPS_Dict(EPS_Con));
else
EPS_Con_dump = zeros(87,1);
for m = 1:52
EPS_Con_dump(m) = FIBF_Con(m);
end
for m = 1:35
EPS_Con_dump(m+52) = CMs(m);
end
dump_vars(export_mod_file_base + "last.txt", EPS_Dict(EPS_Con_dump));
end
export_mod_enabled = 0;
end

% Step III: Calculate the mass balanec equation for the EPS model. This basically need to make sure that the variables
% used in the mass balance equation should be in exact sequence with the sequence used in the inialization.

Expand Down Expand Up @@ -95,3 +76,18 @@
%EPS_DYDT(62) = BF2EPS_vbfn2 - PS2EPS_v3 - 1 * PS2EPS_NADPH/(PS2EPS_NADPH + 0.5) ;
EPS_DYDT(62) = BF2EPS_vbfn2/2 - PS2EPS_v3;% - 1 * PS2EPS_NADPH/(PS2EPS_NADPH + 0.5) ; %QF changed /2 and ;% - 1 * PS2EPS_NADPH/(PS2EPS_NADPH + 0.5)
EPS_DYDT(29) = EPS_DYDT(62);

global export_mod_enabled;
if export_mod_enabled == 1
EPS_Con_dump = EPS_Con;
if t ~= 0
EPS_Con_dump = zeros(87,1);
for m = 1:52
EPS_Con_dump(m) = FIBF_Con(m);
end
for m = 1:35
EPS_Con_dump(m+52) = CMs(m);
end
end
export_mod_dict(t, "EPS", EPS_Con_dump, "");
end
5 changes: 4 additions & 1 deletion FIBF_MB.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,7 @@
FIBF_mb ( 12 ) = GPQH2_t; % QH2 The PQH2 concentration; the coefficient 2 represent the fact that 2 protons were taken up by one Q2-.
FIBF_mb ( 51 ) = GPQH2_t; % QH2 The PQH2 concentration; the coefficient 2 represent the fact that 2 protons were taken up by one Q2-.

export_mod_dict("FIBF", FIBF_Con, "");
global export_mod_enabled;
if export_mod_enabled == 1
export_mod_dict(t, "FIBF", FIBF_Con);
end
6 changes: 4 additions & 2 deletions FI_Rate.m
Original file line number Diff line number Diff line change
Expand Up @@ -375,5 +375,7 @@
FI_Vel ( 57 ) = vP680_d;
FI_Vel ( 58 ) = vP680_f;


export_mod_dict("FI", FI_Con, "");
global export_mod_enabled;
if export_mod_enabled == 1
export_mod_dict(t, "FI", FI_Con, "");
end
Loading

0 comments on commit 67c9047

Please sign in to comment.