root_to_shoot

Two models, a root model and a shoot model, that are both run via wrappers around functions. The root model receives the initial root mass, growth rate, and time steps from files. For each time step, the root model computes the new root mass and sends it to the shoot model. The shoot model receives the initial shoot mass, growth rate, and time steps from files. For each time step, the shoot model receives the new root mass from the root model, calculates the next shoot mass and outputs it to a file.

Mixed Version

Model Code:

 1import time
 2
 3
 4def calc_shoot_mass(r_s, dt, S_t, R_t, R_tp1):
 5    r"""Calculate the shoot mass.
 6
 7    Args:
 8        r_s (float): Relative shoot growth rate.
 9        dt (float): The time step.
10        S_t (float): Previous shoot mass.
11        R_t (float): Previous root mass.
12        R_tp1 (float): Root mass at the next timestep.
13
14    Returns:
15        float: Shoot mass at the next timestep.
16
17    """
18    time.sleep(0.1)  # To simulate a longer calculation
19    return (S_t * r_s * dt) + S_t - (R_tp1 - R_t)

Model YAML:

 1model:
 2  name: RootModel
 3  language: c
 4  args: ./src/root_wrapper.c
 5  inputs:
 6    - name: root_growth_rate
 7      units: hr**-1
 8    - name: init_root_mass
 9      units: g
10    - name: root_time_step
11      units: hr
12  outputs:
13    - name: next_root_mass
14      units: g
 1model:
 2  name: ShootModel
 3  language: python
 4  args: ./src/shoot_wrapper.py
 5  inputs:
 6    - name: shoot_growth_rate
 7      units: d**-1
 8    - name: init_shoot_mass
 9      units: kg
10    - name: shoot_time_step
11      units: d
12    - name: next_root_mass
13      units: kg
14  outputs:
15    - name: next_shoot_mass
16      units: kg
 1connections:
 2  # Root input connections
 3  - input: ./Input/root_growth_rate.txt
 4    output: root_growth_rate
 5    filetype: table
 6  - input: ./Input/init_root_mass.txt
 7    output: init_root_mass
 8    filetype: table
 9  - input: ./Input/timesteps.txt
10    output: root_time_step
11    filetype: table
12
13  # Root-to-shoot connection
14  - input: next_root_mass
15    output: next_root_mass
16
17  # Shoot input connections
18  - input: ./Input/shoot_growth_rate.txt
19    output: shoot_growth_rate
20    filetype: table
21  - input: ./Input/init_shoot_mass.txt
22    output: init_shoot_mass
23    filetype: table
24  - input: ./Input/timesteps.txt
25    output: shoot_time_step
26    filetype: table
27
28  # Shoot output connection
29  - input: next_shoot_mass
30    output: ./Output/shoot_output.txt
31    filetype: table
32    field_names: shoot_mass

Mixed w/o Matlab Version

Model Code:

 1import time
 2
 3
 4def calc_shoot_mass(r_s, dt, S_t, R_t, R_tp1):
 5    r"""Calculate the shoot mass.
 6
 7    Args:
 8        r_s (float): Relative shoot growth rate.
 9        dt (float): The time step.
10        S_t (float): Previous shoot mass.
11        R_t (float): Previous root mass.
12        R_tp1 (float): Root mass at the next timestep.
13
14    Returns:
15        float: Shoot mass at the next timestep.
16
17    """
18    time.sleep(0.1)  # To simulate a longer calculation
19    return (S_t * r_s * dt) + S_t - (R_tp1 - R_t)

Model YAML:

 1model:
 2  name: RootModel
 3  language: c
 4  args: ./src/root_wrapper.c
 5  inputs:
 6    - name: root_growth_rate
 7      units: hr**-1
 8    - name: init_root_mass
 9      units: g
10    - name: root_time_step
11      units: hr
12  outputs:
13    - name: next_root_mass
14      units: g
 1model:
 2  name: ShootModel
 3  language: python
 4  args: ./src/shoot_wrapper.py
 5  inputs:
 6    - name: shoot_growth_rate
 7      units: d**-1
 8    - name: init_shoot_mass
 9      units: kg
10    - name: shoot_time_step
11      units: d
12    - name: next_root_mass
13      units: kg
14  outputs:
15    - name: next_shoot_mass
16      units: kg
 1connections:
 2  # Root input connections
 3  - input: ./Input/root_growth_rate.txt
 4    output: root_growth_rate
 5    filetype: table
 6  - input: ./Input/init_root_mass.txt
 7    output: init_root_mass
 8    filetype: table
 9  - input: ./Input/timesteps.txt
10    output: root_time_step
11    filetype: table
12
13  # Root-to-shoot connection
14  - input: next_root_mass
15    output: next_root_mass
16
17  # Shoot input connections
18  - input: ./Input/shoot_growth_rate.txt
19    output: shoot_growth_rate
20    filetype: table
21  - input: ./Input/init_shoot_mass.txt
22    output: init_shoot_mass
23    filetype: table
24  - input: ./Input/timesteps.txt
25    output: shoot_time_step
26    filetype: table
27
28  # Shoot output connection
29  - input: next_shoot_mass
30    output: ./Output/shoot_output.txt
31    filetype: table
32    field_names: shoot_mass

C Version

Model Code:

Model YAML:

 1model:
 2  name: RootModel
 3  language: c
 4  args: ./src/root_wrapper.c
 5  inputs:
 6    - name: root_growth_rate
 7      units: hr**-1
 8    - name: init_root_mass
 9      units: g
10    - name: root_time_step
11      units: hr
12  outputs:
13    - name: next_root_mass
14      units: g
 1connections:
 2  # Input connections
 3  - input: ./Input/root_growth_rate.txt
 4    output: root_growth_rate
 5    filetype: table
 6  - input: ./Input/init_root_mass.txt
 7    output: init_root_mass
 8    filetype: table
 9  - input: ./Input/timesteps.txt
10    output: root_time_step
11    filetype: table
12
13  # Output connections
14  - input: next_root_mass
15    output: ./Output/root_output.txt
16    filetype: table
17    field_names: root_mass

Python Version

Model Code:

 1import time
 2
 3
 4def calc_shoot_mass(r_s, dt, S_t, R_t, R_tp1):
 5    r"""Calculate the shoot mass.
 6
 7    Args:
 8        r_s (float): Relative shoot growth rate.
 9        dt (float): The time step.
10        S_t (float): Previous shoot mass.
11        R_t (float): Previous root mass.
12        R_tp1 (float): Root mass at the next timestep.
13
14    Returns:
15        float: Shoot mass at the next timestep.
16
17    """
18    time.sleep(0.1)  # To simulate a longer calculation
19    return (S_t * r_s * dt) + S_t - (R_tp1 - R_t)

Model YAML:

 1model:
 2  name: ShootModel
 3  language: python
 4  args: ./src/shoot_wrapper.py
 5  inputs:
 6    - name: shoot_growth_rate
 7      units: d**-1
 8    - name: init_shoot_mass
 9      units: kg
10    - name: shoot_time_step
11      units: d
12    - name: next_root_mass
13      units: kg
14  outputs:
15    - name: next_shoot_mass
16      units: kg
 1connections:
 2  # Input connections
 3  - input: ./Input/shoot_growth_rate.txt
 4    output: shoot_growth_rate
 5    filetype: table
 6  - input: ./Input/init_shoot_mass.txt
 7    output: init_shoot_mass
 8    filetype: table
 9  - input: ./Input/timesteps.txt
10    output: shoot_time_step
11    filetype: table
12  - input: ./Input/root_output.txt
13    output: next_root_mass
14    filetype: table
15
16  # Output connections
17  - input: next_shoot_mass
18    output: ./Output/shoot_output.txt
19    filetype: table
20    field_names: shoot_mass