Skip to content

Commit a036613

Browse files
committed
Add other calculated variables & move from drivers to Variables
Reconcile alternate inputs (e.g. CO2, O2, Light) Disambiguate light by setting PAR to have W/s units & PPFD to have umol/m2/s Updated condition to actual use input O2 concentration Add tables from Zhu2012 as csv Add explicit parameters for constants defined in source code & Zhu2021 tables
1 parent c340711 commit a036613

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3267
-288
lines changed

TODO.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@
2222
- Standardize setVar for control parameters on Variables
2323
- Update variables from yggdrasil document
2424
- Only export select members of value set
25+
- Include yaml file in installation (e.g. share)
26+
- Fix variable names in BF_Pool

include/Variables.hpp

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,11 @@ class Variables : public VALUE_SET_PARENT(Variables, Variables, MODULE_ALL, PARA
172172
public:
173173

174174
/**
175-
Check if a variable was updated since the last time the input
176-
was finalized.
175+
Check if a variable was explicitly updated since the last time
176+
the input was finalized.
177177
\param[in] name Variable name.
178-
\param[in] ignoreClassFlag If true, only return true if the
179-
specific variable was updated.
180178
*/
181-
EPHOTO_API bool inputUpdated(const std::string& name,
182-
const bool ignoreClassFlag=false) const;
179+
EPHOTO_API bool inputUpdated(const std::string& name) const;
183180
/**
184181
Throw an error if the named variable was updated.
185182
*/
@@ -238,6 +235,8 @@ class Variables : public VALUE_SET_PARENT(Variables, Variables, MODULE_ALL, PARA
238235
are not stored on Variables instances.
239236
\param[in] subset Subset of parameters to output.
240237
\param[in] additionalVars Map of additional names & values to dump.
238+
\param[in] skip_calculated If true, don't output the calculated
239+
variables.
241240
*/
242241
void dump(const std::string& filename,
243242
const bool includeSkipped = false,
@@ -247,7 +246,8 @@ class Variables : public VALUE_SET_PARENT(Variables, Variables, MODULE_ALL, PARA
247246
const std::map<std::string, std::string>& key_aliases={},
248247
const std::map<MODULE, const ValueSet_t*>& conditions={},
249248
const std::vector<std::string>& subset={},
250-
const std::map<std::string, double>& additionalVars={}) const;
249+
const std::map<std::string, double>& additionalVars={},
250+
const bool skip_calculated=false) const;
251251
/**
252252
Serialize all parameters attached to this instance to an output
253253
stream.
@@ -263,6 +263,8 @@ class Variables : public VALUE_SET_PARENT(Variables, Variables, MODULE_ALL, PARA
263263
are not stored on Variables instances.
264264
\param[in] subset Subset of parameters to output.
265265
\param[in] additionalVars Map of additional names & values to dump.
266+
\param[in] skip_calculated If true, don't output the calculated
267+
variables.
266268
\returns Updated output stream.
267269
*/
268270
std::ostream& dump(std::ostream& out,
@@ -273,7 +275,8 @@ class Variables : public VALUE_SET_PARENT(Variables, Variables, MODULE_ALL, PARA
273275
const std::map<std::string, std::string>& key_aliases={},
274276
const std::map<MODULE, const ValueSet_t*>& conditions={},
275277
const std::vector<std::string>& subset={},
276-
const std::map<std::string, double>& additionalVars={}) const;
278+
const std::map<std::string, double>& additionalVars={},
279+
const bool skip_calculated=false) const;
277280
/**
278281
Serialize parameters for a single value set to an output stream.
279282
\param[in] module ID for module that should be serialized.
@@ -649,31 +652,75 @@ class Variables : public VALUE_SET_PARENT(Variables, Variables, MODULE_ALL, PARA
649652
\param[in] name String identifying the variable.
650653
\param[in] isGlymaID If true, name will be treated as a GlymaID.
651654
If false, name will be treated as the variable name.
655+
\param[in] conditions Map of conditions for composite modules that
656+
are not stored on Variables instances.
652657
\returns Variable value.
653658
*/
654659
EPHOTO_API double getVar(const MODULE& mod, const PARAM_TYPE& pt,
655660
const std::string& name,
656-
const bool& isGlymaID = false) const;
661+
const bool& isGlymaID = false,
662+
const std::map<MODULE, const ValueSet_t*>& conditions={}) const;
657663
/**
658664
Get the value of a variable in a value set.
659665
\param[in] mod Module associated with the value set that the
660666
variable is part of.
661667
\param[in] pt Parameter type associated with the value set that the
662668
variable is part of.
663669
\param[in] key Key identifying the variable.
670+
\param[in] conditions Map of conditions for composite modules that
671+
are not stored on Variables instances.
664672
\returns Variable value.
665673
*/
666674
EPHOTO_API double getVar(const MODULE& mod, const PARAM_TYPE& pt,
667-
const int& key) const;
675+
const int& key,
676+
const std::map<MODULE, const ValueSet_t*>& conditions={}) const;
668677
/**
669678
Get the value of a variable in a value set.
670679
\param[in] k String identifying the variable.
671680
\param[in] isGlymaID If true, name will be treated as a GlymaID.
672681
If false, name will be treated as the variable name.
682+
\param[in] conditions Map of conditions for composite modules that
683+
are not stored on Variables instances.
673684
\returns Variable value.
674685
*/
675686
EPHOTO_API double getVar(const std::string& k,
676-
const bool& isGlymaID = false) const;
687+
const bool& isGlymaID = false,
688+
const std::map<MODULE, const ValueSet_t*>& conditions={}) const;
689+
/**
690+
Get the value of a calculated quantity using variables from the
691+
current value sets.
692+
\param[in] name String identifying the variable.
693+
\param[in] conditions Map of conditions for composite modules that
694+
are not stored on Variables instances.
695+
\returns Variable value.
696+
*/
697+
EPHOTO_API double getVarCalculated(const std::string& name,
698+
const std::map<MODULE, const ValueSet_t*>& conditions={}) const;
699+
700+
/**
701+
Get information about the modules required to calculate variables.
702+
These variables can be retrieved via the Variables::getVar,
703+
Variables::getVarCalculated or Variables::getCalculatedVars
704+
methods.
705+
*/
706+
EPHOTO_API static const std::map<std::string, std::vector<MODULE> >&
707+
getCalculatedVariableRegistry();
708+
/**
709+
Get the set of variable names that can be calculated. These
710+
variables can be retrieved via the Variables::getVar,
711+
Variables::getVarCalculated or Variables::getCalculatedVars
712+
methods.
713+
*/
714+
EPHOTO_API const std::vector<std::string>&
715+
getCalculatedVarNames() const;
716+
/**
717+
Populate a map with calculated variables.
718+
\param[out] dest Map that should be populated.
719+
\param[in] conditions Map of conditions for composite modules that
720+
are not stored on Variables instances.
721+
*/
722+
EPHOTO_API void getCalculatedVars(std::map<std::string, double>& dest,
723+
const std::map<MODULE, const ValueSet_t*>& conditions) const;
677724
/**
678725
Get the documentation string for a variable in a value set.
679726
\param[in] mod Module associated with the value set that the

include/conditions/FIBFCondition.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define PARENT_FIBF EPS
3535
#define NRATIO_FIBF 0
3636
#define CHILDREN_FIBF BF, FI
37-
#define PARAM_TYPES_FIBF COND, POOL
37+
#define PARAM_TYPES_FIBF COND, POOL, RC
3838

3939
namespace ePhotosynthesis {
4040

include/conditions/RedoxRegCondition.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define PARENT_RedoxReg RedoxReg
3232
#define NRATIO_RedoxReg 0
3333
#define CHILDREN_RedoxReg RA
34-
#define PARAM_TYPES_RedoxReg COND, VEL
34+
#define PARAM_TYPES_RedoxReg COND, VEL, RC
3535
#define CONNECT_RedoxReg
3636
#define COUNT_RedoxReg
3737
#define CONTROL_RedoxReg

include/drivers/driver.hpp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,11 @@ class Driver : public DriverParam {
250250

251251
/**
252252
Get output variables.
253-
\param theVars Structure containing current variables.
253+
\param[in] theVars Structure containing current variables.
254+
\param[in] con Pointer to current conditions.
254255
*/
255-
void getOutputVars(Variables* theVars);
256+
void getOutputVars(const Variables* theVars=nullptr,
257+
const ValueSet_t* con=nullptr);
256258

257259
/**
258260
Set the output variables.
@@ -268,24 +270,22 @@ class Driver : public DriverParam {
268270

269271
/**
270272
Get a variable given the current state defined by theVars.
271-
\param[in] theVars Current variable state.
272273
\param[in] k Name of variable to return.
273-
*/
274-
double getVar(const Variables* theVars, const std::string& k) const;
275-
276-
/**
277-
Populate a map with calculated variables.
278274
\param[in] theVars Current variable state.
279-
\param[out] dest Map that should be populated.
275+
\param[in] con Pointer to current conditions.
280276
*/
281-
void getCalculatedVars(const Variables* theVars,
282-
std::map<std::string, double>& dest) const;
277+
double getVar(const std::string& k, const Variables* theVars=nullptr,
278+
const ValueSet_t* con=nullptr) const;
279+
283280
/**
284-
Get a map containing calculated variables.
281+
Get a variable given the current state defined by theVars.
282+
\param[in] k Name of variable to return.
285283
\param[in] theVars Current variable state.
286-
\returns Calculated variables.
284+
\param[in] conditions Map of conditions for composite modules that
285+
are not stored on Variables instances.
287286
*/
288-
std::map<std::string, double> getCalculatedVars(const Variables* theVars) const;
287+
double getVar(const std::string& k, const Variables* theVars,
288+
const std::map<MODULE, const ValueSet_t*>& conditions) const ;
289289

290290
/**
291291
Runs the solver one more time on the intermediate results to get the solution at the end time
@@ -301,7 +301,7 @@ class Driver : public DriverParam {
301301
should be created from.
302302
\returns Conditions value set.
303303
*/
304-
virtual ValueSet_t* currentConditions(realtype *x = nullptr) {
304+
virtual ValueSet_t* currentConditions(realtype *x = nullptr) const {
305305
UNUSED(x);
306306
return nullptr;
307307
}
@@ -416,13 +416,6 @@ class Driver : public DriverParam {
416416
\param user_data Any user supplied data.
417417
*/
418418
static int calculate(realtype t, N_Vector u, N_Vector u_dot, void *user_data);
419-
/**
420-
Get the set of variable names that the driver can calculate. These
421-
variables can be retrieved via the Driver::getVar method or
422-
getCalculatedVars.
423-
*/
424-
static const std::vector<std::string>&
425-
getCalculatedVarNames();
426419

427420

428421
#ifdef SUNDIALS_CONTEXT_REQUIRED
@@ -552,7 +545,7 @@ const MODULE DriverBase<T, M>::module = M;
552545
/** \copydoc drivers::DriverBase::enableC3 */ \
553546
static void enableC3(const bool x = true); \
554547
/** \copydoc drivers::Driver::currentConditions */ \
555-
ValueSet_t* currentConditions(realtype *x = nullptr) override; \
548+
ValueSet_t* currentConditions(realtype *x = nullptr) const override; \
556549
/** \copydoc drivers::Driver::setup_connections */ \
557550
void setup_connections(Variables* theVars) override; \
558551
/** \copydoc drivers::Driver::setup_variables */ \
@@ -589,7 +582,7 @@ private: \
589582
void name ## Driver::enableC3(const bool x) { \
590583
return VARS_CLASS_CALL(enableC3, (x), name, MOD); \
591584
} \
592-
ValueSet_t* name ## Driver::currentConditions(realtype *x) { \
585+
ValueSet_t* name ## Driver::currentConditions(realtype *x) const { \
593586
if (x) { \
594587
return new VARS_CLASS_VAR(name, COND)(x); \
595588
} \

include/enums/enums_helpers.hpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ namespace ePhotosynthesis {
958958
EPS_ATP_Rate , \
959959
_Pi , \
960960
PMODTEM , \
961+
F , \
961962
RT , \
962963
DeltaGo , \
963964
MAX
@@ -1318,6 +1319,7 @@ namespace ePhotosynthesis {
13181319
Q10_10 , \
13191320
Q10_13 , \
13201321
Q10_23 , \
1322+
F , \
13211323
R , \
13221324
c_c , \
13231325
dHa_c , \
@@ -1634,7 +1636,9 @@ namespace ePhotosynthesis {
16341636
}
16351637
namespace ePhotosynthesis {
16361638
#define MEMBERS_FIBFRC \
1637-
NONE , \
1639+
NONE , \
1640+
RC0 , \
1641+
RC , \
16381642
MAX
16391643
#ifdef EPHOTO_USE_SCOPED_ENUM
16401644
enum class ENUM_FIBF_RC : int {
@@ -1916,11 +1920,17 @@ namespace ePhotosynthesis {
19161920
}
19171921
namespace ePhotosynthesis {
19181922
#define MEMBERS_RedoxRegRC \
1919-
NONE , \
1920-
Fd_Thio_ET , \
1921-
ThioT , \
1922-
Thio_Oxidation , \
1923-
Thion0 , \
1923+
NONE , \
1924+
Thiom0 , \
1925+
FBPase0 , \
1926+
SBPase0 , \
1927+
PRK0 , \
1928+
ATPase0 , \
1929+
Em_Thiom , \
1930+
Em_FBPase , \
1931+
Em_SBPase , \
1932+
Em_PRK , \
1933+
Em_ATPase , \
19241934
MAX
19251935
#ifdef EPHOTO_USE_SCOPED_ENUM
19261936
enum class ENUM_RedoxReg_RC : int {
@@ -1947,6 +1957,8 @@ namespace ePhotosynthesis {
19471957
ko , \
19481958
k7 , \
19491959
kr , \
1960+
kn7 , \
1961+
RCA , \
19501962
MAX
19511963
#ifdef EPHOTO_USE_SCOPED_ENUM
19521964
enum class ENUM_RuACT_RC : int {

include/rc/FIBFRC.hpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#pragma once
2+
3+
/**********************************************************************************************************************************************
4+
* Copyright Xin-Guang Zhu, Yu Wang, Donald R. ORT and Stephen P. LONG
5+
*
6+
* CAS-MPG Partner Institute for Computational Biology, Shanghai Institutes for Biological Sciences, CAS, Shanghai,200031
7+
* China Institute of Genomic Biology and Department of Plant Biology, Shanghai Institutes for Biological Sciences, CAS, Shanghai,200031
8+
* University of Illinois at Urbana Champaign
9+
* Global Change and Photosynthesis Research Unit, USDA/ARS, 1406 Institute of Genomic Biology, Urbana, IL 61801, USA.
10+
*
11+
* Converted from Matlab to C++ by Douglas N. Friedel, National Center for Supercomputing Applications (2020)
12+
*
13+
* This file is part of e-photosynthesis.
14+
*
15+
* e-photosynthesis is free software; you can redistribute it and/or modify
16+
* it under the terms of the GNU General Public License as published by
17+
* the Free Software Foundation;
18+
*
19+
* e-photosynthesis is distributed in the hope that it will be useful,
20+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
* GNU General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU General Public License (GPL)
25+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26+
*
27+
**********************************************************************************************************************************************/
28+
29+
#include "../definitions.hpp"
30+
#include "RCBase.hpp"
31+
32+
namespace ePhotosynthesis {
33+
namespace RC {
34+
35+
// class for holding FIBFRC data
36+
class FIBFRC : public RCBase<FIBFRC, MODULE_FIBF> {
37+
public:
38+
DECLARE_VALUE_SET(FIBFRC, RCBase<FIBFRC, MODULE_FIBF>)
39+
FIBFRC() : RCBase<FIBFRC, MODULE_FIBF>() {
40+
initMembers();
41+
}
42+
43+
/**
44+
Copy constructor that makes a deep copy of the given object
45+
46+
@param other The FIBFRC object to copy
47+
*/
48+
FIBFRC(const FIBFRC &other) : RCBase<FIBFRC, MODULE_FIBF>(other) {
49+
initMembers();
50+
*this = other;
51+
}
52+
FIBFRC& operator=(const FIBFRC &other) {
53+
RC0 = other.RC0; // The maximal relaxation constant for heat dissipation, which is one term borrowed from Laisk et al., 1997;
54+
RC = other.RC;
55+
copyMembers(other);
56+
return *this;
57+
}
58+
59+
};
60+
61+
DEFINE_VALUE_SET_HEADER(FIBFRC);
62+
63+
} // namespace RC
64+
} // namespace ePhotosynthesis

include/rc/RCAll.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@
2929
#include "RCBase.hpp"
3030
#include "BFRC.hpp"
3131
#include "FIRC.hpp"
32+
#include "FIBFRC.hpp"
3233
#include "RROEARC.hpp"
3334
#include "RuACTRC.hpp"
35+
#include "RedoxRegRC.hpp"

include/rc/RCBase.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828

2929
#include "../ValueSet.hpp"
3030

31-
#define MEMBERS_RC BF, FI, RROEA, RuACT
31+
#define MEMBERS_RC BF, FI, FIBF, RROEA, RuACT, RedoxReg
3232

3333
DECLARE_PARAM_BASE(RC)

0 commit comments

Comments
 (0)