Skip to content

Commit

Permalink
decouple asismilation from ff16
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Mar 25, 2020
1 parent 88a9f5b commit 39acd5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions inst/include/plant/models/assimilation.h
Expand Up @@ -3,13 +3,14 @@
#define PLANT_PLANT_ASSIMILATION_H_

#include <memory>
#include <plant/models/ff16_environment.h>
#include <plant/environment.h>
#include <plant/control.h>
#include <plant/qag_internals.h> // quadrature::intervals_type
#include <plant/internals.h> // quadrature::intervals_type

namespace plant {

template <typename E>
class Assimilation {
public:

Expand All @@ -27,8 +28,8 @@ class Assimilation {
//
// NOTE: In contrast with Daniel's implementation (but following
// Falster 2012), we do not normalise by a_y*a_bio here.
double assimilate(Control& control,
const FF16_Environment& environment,
double assimilate(Control& control,
const E& environment,
double height,
double area_leaf,
bool reuse_intervals
Expand Down Expand Up @@ -63,7 +64,7 @@ class Assimilation {
// [eqn 12]; i.e., A_lf(A_0v, E(z,a)) * q(z,h(m_l))
// where `z` is height.
/* double compute_assimilation_x(Control control, double x, double height, */
/* const FF16_Environment& environment) const { */
/* const E& environment) const { */
/* if (control.plant_assimilation_over_distribution) { */
/* return compute_assimilation_p(x, height, environment); */
/* } else { */
Expand All @@ -72,13 +73,13 @@ class Assimilation {
/* } */

double compute_assimilation_h(double z, double height,
const FF16_Environment& environment) const {
return assimilation_leaf(environment.canopy_openness(z)) * q(z, height);
const E& environment) const {
return assimilation_leaf(environment.get_environment_at_height(z)) * q(z, height);
}

double compute_assimilation_p(double p, double height,
const FF16_Environment& environment) const {
return assimilation_leaf(environment.canopy_openness(Qp(p, height)));
const E& environment) const {
return assimilation_leaf(environment.get_environment_at_height(Qp(p, height)));
}

// [Appendix S6] Per-leaf photosynthetic rate.
Expand Down
2 changes: 1 addition & 1 deletion inst/include/plant/models/ff16_environment.h
Expand Up @@ -49,7 +49,7 @@ class FF16_Environment : public Environment {
// TODO: move these to Environment
template <typename Function>
void compute_environment(Function f_compute_competition,
double height_max) {
double height_max) {
const double lower_bound = 0.0;
double upper_bound = height_max;

Expand Down
2 changes: 1 addition & 1 deletion inst/include/plant/models/ff16_strategy.h
Expand Up @@ -226,7 +226,7 @@ class FF16_Strategy: public Strategy<FF16_Environment> {

std::string name;

Assimilation assimilator;
Assimilation<FF16_Environment> assimilator;

// Translate generic methods to FF16 strategy leaf area methods

Expand Down

0 comments on commit 39acd5d

Please sign in to comment.