Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
698 changes: 349 additions & 349 deletions src/openalea/cnwgrass/cnmetabolism/model.py

Large diffs are not rendered by default.

559 changes: 529 additions & 30 deletions src/openalea/cnwgrass/cnmetabolism/simulation.py

Large diffs are not rendered by default.

112 changes: 56 additions & 56 deletions src/openalea/cnwgrass/gasexchange/model.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/openalea/cnwgrass/gasexchange/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def run(self, Ta, ambient_CO2, RH, Ur):
the results in :attr:`outputs`.

:param float Ta: air temperature at t (degree Celsius)
:param float ambient_CO2: air CO2 at t (µmol mol-1)
:param float ambient_CO2: air CO2 at t (µmol mol-1)
:param float RH: relative humidity at t (decimal fraction)
:param float Ur: wind speed at the top of the canopy at t (m s-1)
"""
Expand All @@ -126,11 +126,11 @@ def run(self, Ta, ambient_CO2, RH, Ur):
Ts = self.inputs['axes'][axis_id]['SAM_temperature']

else:
Ts = Ta # Initial value of Ts (°C)
Ts = Ta # Initial value of Ts (°C)
if element_inputs['Ci'] is None or np.isnan(element_inputs['Ci']):
Ci = ambient_CO2
else:
Ci = element_inputs['Ci'] #: previous organ internal CO2 concentration (µmol mol-1) todo Ci = parameters.Ci_init_ratio * ambient_CO2 see with Victoria if we keep this
Ci = element_inputs['Ci'] #: previous organ internal CO2 concentration (µmol mol-1) todo Ci = parameters.Ci_init_ratio * ambient_CO2 see with Victoria if we keep this
height_canopy = self.inputs['axes'][axis_id]['height_canopy']
water_potential = element_inputs.get('water_potential', None)

Expand Down
69 changes: 36 additions & 33 deletions src/openalea/cnwgrass/growth/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Simulation(object):
"""The Simulation class permits to initialize and run a simulation.
"""

def __init__(self, delta_t=1, hydraulics=False, update_parameters=None):
def __init__(self, delta_t=1, hydraulics=False, update_parameters=None, cnwgrass_roots=True):
"""
:param int delta_t: the delta t of the simulation (in seconds)
:param bool hydraulics: if True the model will assume the coupling to the turgor-driven growth model
Expand Down Expand Up @@ -81,6 +81,8 @@ def __init__(self, delta_t=1, hydraulics=False, update_parameters=None):
else:
warnings.warn(f"Parameter '{key}' is not defined in class self.self.model.parameters.")

self.cnwgrass_roots = cnwgrass_roots

def initialize(self, inputs):
"""
Initialize :attr:`inputs` from `inputs`.
Expand Down Expand Up @@ -260,13 +262,13 @@ def run(self, postflowering_stages=False):
curr_hiddenzone_outputs['AA_consumption_mstruct'] = self.model.calculate_s_Nstruct_amino_acids((delta_leaf_enclosed_Nstruct + delta_internode_enclosed_Nstruct),
delta_lamina_Nstruct,
delta_sheath_Nstruct,
delta_internode_Nstruct) #: Consumption of amino acids due to mstruct growth (µmol N)
delta_internode_Nstruct) #: Consumption of amino acids due to mstruct growth (µmol N)
curr_hiddenzone_outputs['sucrose_consumption_mstruct'] = self.model.calculate_s_mstruct_sucrose((delta_leaf_enclosed_mstruct + delta_internode_enclosed_mstruct),
delta_lamina_mstruct,
delta_sheath_mstruct,
curr_hiddenzone_outputs[
'AA_consumption_mstruct']) #: Consumption of sucrose due to mstruct growth (µmol C)
curr_hiddenzone_outputs['Respi_growth'] = RespirationModel.R_growth(curr_hiddenzone_outputs['sucrose_consumption_mstruct']) #: Respiration growth (µmol C)
'AA_consumption_mstruct']) #: Consumption of sucrose due to mstruct growth (µmol C)
curr_hiddenzone_outputs['Respi_growth'] = RespirationModel.R_growth(curr_hiddenzone_outputs['sucrose_consumption_mstruct']) #: Respiration growth (µmol C)

# -- Update of hiddenzone outputs
curr_hiddenzone_outputs['leaf_enclosed_mstruct'] += delta_leaf_enclosed_mstruct
Expand Down Expand Up @@ -407,32 +409,33 @@ def run(self, postflowering_stages=False):
# --------------------------------
# -------------- Roots -----------
# --------------------------------
for root_id, root_inputs in all_roots_inputs.items():
curr_root_outputs = all_roots_outputs[root_id]

axis_id = root_id[:2]
curr_axis_outputs = all_axes_outputs[axis_id]

# Temperature-compensated time (delta_teq)
delta_teq = all_axes_inputs[axis_id]['delta_teq_roots']

# Growth
xylem_water_potential = all_axes_inputs[axis_id].get('xylem_water_potential') # Set at None if hydraulics is False
mstruct_C_growth, mstruct_growth, Nstruct_growth, Nstruct_N_growth = self.model.calculate_roots_mstruct_growth(root_inputs['sucrose'], root_inputs['amino_acids'],
root_inputs['mstruct'], delta_teq, postflowering_stages,
all_axes_inputs[axis_id]['nb_leaves'], xylem_water_potential)
# Respiration growth
curr_root_outputs['Respi_growth'] = RespirationModel.R_growth(mstruct_C_growth)

# Update of root outputs
curr_root_outputs['mstruct'] += mstruct_growth
curr_root_outputs['AA_consumption_mstruct'] = Nstruct_N_growth
curr_root_outputs['sucrose_consumption_mstruct'] = self.model.calculate_roots_s_mstruct_sucrose(mstruct_growth, Nstruct_N_growth)
curr_root_outputs['sucrose'] -= (curr_root_outputs['sucrose_consumption_mstruct'] + curr_root_outputs['Respi_growth'])
curr_root_outputs['Nstruct'] += Nstruct_growth
curr_root_outputs['amino_acids'] -= curr_root_outputs['AA_consumption_mstruct']
curr_root_outputs['delta_mstruct_growth'] = mstruct_growth
self.outputs['roots'][root_id] = curr_root_outputs

# Update of axis outputs
self.outputs['axes'][axis_id] = curr_axis_outputs
if self.cnwgrass_roots:
for root_id, root_inputs in all_roots_inputs.items():
curr_root_outputs = all_roots_outputs[root_id]

axis_id = root_id[:2]
curr_axis_outputs = all_axes_outputs[axis_id]

# Temperature-compensated time (delta_teq)
delta_teq = all_axes_inputs[axis_id]['delta_teq_roots']

# Growth
xylem_water_potential = all_axes_inputs[axis_id].get('xylem_water_potential') # Set at None if hydraulics is False
mstruct_C_growth, mstruct_growth, Nstruct_growth, Nstruct_N_growth = self.model.calculate_roots_mstruct_growth(root_inputs['sucrose'], root_inputs['amino_acids'],
root_inputs['mstruct'], delta_teq, postflowering_stages,
all_axes_inputs[axis_id]['nb_leaves'], xylem_water_potential)
# Respiration growth
curr_root_outputs['Respi_growth'] = RespirationModel.R_growth(mstruct_C_growth)

# Update of root outputs
curr_root_outputs['mstruct'] += mstruct_growth
curr_root_outputs['AA_consumption_mstruct'] = Nstruct_N_growth
curr_root_outputs['sucrose_consumption_mstruct'] = self.model.calculate_roots_s_mstruct_sucrose(mstruct_growth, Nstruct_N_growth)
curr_root_outputs['sucrose'] -= (curr_root_outputs['sucrose_consumption_mstruct'] + curr_root_outputs['Respi_growth'])
curr_root_outputs['Nstruct'] += Nstruct_growth
curr_root_outputs['amino_acids'] -= curr_root_outputs['AA_consumption_mstruct']
curr_root_outputs['delta_mstruct_growth'] = mstruct_growth
self.outputs['roots'][root_id] = curr_root_outputs

# Update of axis outputs
self.outputs['axes'][axis_id] = curr_axis_outputs
Loading
Loading