Crop modules
diffwofost.physical_models.crop.wofost72.Wofost72
Bases: SimulationObject
Top level object organizing the different components of WOFOST.
The CropSimulation object organizes the different processes of the crop simulation. Moreover, it contains the parameters, rate and state variables which are relevant at the level of the entire crop. The processes that are implemented as embedded simulation objects consist of:
1. Phenology (self.pheno)
2. Partitioning (self.part)
3. Assimilation (self.assim)
4. Maintenance respiration (self.mres)
5. Evapotranspiration (self.evtra)
6. Leaf dynamics (self.lv_dynamics)
7. Stem dynamics (self.st_dynamics)
8. Root dynamics (self.ro_dynamics)
9. Storage organ dynamics (self.so_dynamics)
Simulation parameters:
======== =============================================== ======= ========== Name Description Type Unit ======== =============================================== ======= ========== CVL Conversion factor for assimilates to leaves SCr - CVO Conversion factor for assimilates to storage SCr - organs. CVR Conversion factor for assimilates to roots SCr - CVS Conversion factor for assimilates to stems SCr - ======== =============================================== ======= ==========
State variables:
=========== ================================================= ==== ===============
Name Description Pbl Unit
=========== ================================================= ==== ===============
TAGP Total above-ground Production N |kg ha-1|
GASST Total gross assimilation N |kg CH2O ha-1|
MREST Total gross maintenance respiration N |kg CH2O ha-1|
CTRAT Total crop transpiration accumulated over the
crop cycle N cm
CEVST Total soil evaporation accumulated over the
crop cycle N cm
HI Harvest Index (only calculated during N -
finalize())
DOF Date representing the day of finish of the crop N -
simulation.
FINISH_TYPE String representing the reason for finishing the N -
simulation: maturity, harvest, leave death, etc.
=========== ================================================= ==== ===============
Rate variables:
======= ================================================ ==== ============= Name Description Pbl Unit ======= ================================================ ==== ============= GASS Assimilation rate corrected for water stress N |kg CH2O ha-1 d-1| MRES Actual maintenance respiration rate, taking into account that MRES <= GASS. N |kg CH2O ha-1 d-1| ASRC Net available assimilates (GASS - MRES) N |kg CH2O ha-1 d-1| DMI Total dry matter increase, calculated as ASRC times a weighted conversion efficiency. Y |kg ha-1 d-1| ADMI Aboveground dry matter increase Y |kg ha-1 d-1| ======= ================================================ ==== =============
Methods:
-
initialize–Initialize the crop simulation.
-
calc_rates–Calculate the rates of change of the state variables.
-
integrate–Integrate the state variables using the rates of change.
-
finalize–Finalize the crop simulation by computing the Harvest Index.
Attributes:
initialize
initialize(day: date, kiosk: VariableKiosk, parvalues: ParameterProvider, shape: tuple | Size | None = None) -> None
Initialize the crop simulation.
:param day: start date of the simulation
:param kiosk: variable kiosk of this PCSE instance
:param parvalues: ParameterProvider object providing parameters as
key/value pairs
:param shape: Target shape for the state and rate variables.
Source code in src/diffwofost/physical_models/crop/wofost72.py
calc_rates
Calculate the rates of change of the state variables.
Parameters:
-
day(date) –The current date of the simulation.
-
drv(WeatherDataContainer) –A dictionary-like container holding weather data elements as key/value. The values are arrays or scalars. See PCSE documentation for details.
Source code in src/diffwofost/physical_models/crop/wofost72.py
integrate
Integrate the state variables using the rates of change.
Parameters:
-
day(date) –The current date of the simulation.
-
delt(float, default:1.0) –The time step for integration. Defaults to 1.0.
Source code in src/diffwofost/physical_models/crop/wofost72.py
finalize
Finalize the crop simulation by computing the Harvest Index.
Source code in src/diffwofost/physical_models/crop/wofost72.py
diffwofost.physical_models.crop.phenology.DVS_Phenology
Bases: SimulationObject
Implements the algorithms for phenologic development in WOFOST.
Phenologic development in WOFOST is expresses using a unitless scale which takes the values 0 at emergence, 1 at Anthesis (flowering) and 2 at maturity. This type of phenological development is mainly representative for cereal crops. All other crops that are simulated with WOFOST are forced into this scheme as well, although this may not be appropriate for all crops. For example, for potatoes development stage 1 represents the start of tuber formation rather than flowering.
Phenological development is mainly governed by temperature and can be modified by the effects of day length and vernalization during the period before Anthesis. After Anthesis, only temperature influences the development rate.
Simulation parameters
| Name | Description | Type | Unit |
|---|---|---|---|
| TSUMEM | Temperature sum from sowing to emergence | SCr | |
| TBASEM | Base temperature for emergence | SCr | |
| TEFFMX | Maximum effective temperature for emergence | SCr | |
| TSUM1 | Temperature sum from emergence to anthesis | SCr | |
| TSUM2 | Temperature sum from anthesis to maturity | SCr | |
| IDSL | Switch for development options: temp only (0), +daylength | SCr | - |
| (1), +vernalization (>=2) | |||
| DLO | Optimal daylength for phenological development | SCr | hr |
| DLC | Critical daylength for phenological development | SCr | hr |
| DVSI | Initial development stage at emergence (may be >0 for | SCr | - |
| transplanted crops) | |||
| DVSEND | Final development stage | SCr | - |
| DTSMTB | Daily increase in temperature sum as a function of daily | TCr | |
| mean temperature |
State variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| DVS | Development stage | Y | - |
| TSUM | Temperature sum | N | |
| TSUME | Temperature sum for emergence | N | |
| DOS | Day of sowing | N | - |
| DOE | Day of emergence | N | - |
| DOA | Day of Anthesis | N | - |
| DOM | Day of maturity | N | - |
| DOH | Day of harvest | N | - |
| STAGE | Current stage (emerging|vegetative|reproductive|mature) |
N | - |
Rate variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| DTSUME | Increase in temperature sum for emergence | N | |
| DTSUM | Increase in temperature sum for anthesis or maturity | N | |
| DVR | Development rate | Y |
External dependencies:
None
Signals sent or handled
DVS_Phenology sends the crop_finish signal when maturity is
reached and the end_type is 'maturity' or 'earliest'.
Gradient mapping (which parameters have a gradient):
| Output | Parameters influencing it |
|---|---|
| DVS | TSUMEM, TBASEM, TEFFMX,TSUM1, TSUM2, DLO, DLC, DVSI, |
| DVSEND, DTSMTB, VERNSAT, VERNBASE, VERNDVS | |
| TSUM | DVSI, DVSEND, DTSMTB, VERNSAT, VERNBASE, VERNDVS |
| TSUME | TBASEM, TEFFMX |
[!NOTE] Notice that the gradient ∂DVS/∂TEFFMX is zero.
[!NOTE] The parameter IDSL it is not differentiable since it is a switch.
Methods:
-
initialize–:param day: start date of the simulation
-
calc_rates–Compute daily phenological development rates.
-
integrate–Integrate phenology states and manage stage transitions.
Attributes:
initialize
:param day: start date of the simulation
:param kiosk: variable kiosk of this PCSE instance
:param parvalues: ParameterProvider object providing parameters as
key/value pairs
Source code in src/diffwofost/physical_models/crop/phenology.py
calc_rates
Compute daily phenological development rates.
Parameters:
-
day(date) –Current simulation date.
-
drv–Meteorological driver object with at least TEMP and LAT.
Logic
- Photoperiod reduction (DVRED) if IDSL >= 1 using daylength.
- Vernalisation factor (VERNFAC) if IDSL >= 2 and in vegetative stage.
- Stage-specific:
- emerging: temperature sum for emergence (DTSUME), DVR via TSUMEM.
- vegetative: temperature sum (DTSUM) scaled by VERNFAC and DVRED.
- reproductive: temperature sum (DTSUM) only temperature-driven.
- mature: all rates zero.
Sets
r.DTSUME, r.DTSUM, r.DVR.
Raises:
-
PCSEError–If STAGE unrecognized.
Source code in src/diffwofost/physical_models/crop/phenology.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
integrate
Integrate phenology states and manage stage transitions.
Parameters:
-
day(date) –Current simulation day.
-
delt(float, default:1.0) –Timestep length in days (default 1.0).
Sequence
- Integrates vernalisation module if active and in vegetative stage.
- Accumulates TSUME, TSUM, advances DVS by DVR.
- Checks threshold crossings to move through stages: emerging -> vegetative (DVS >= 0) vegetative -> reproductive (DVS >= 1) reproductive -> mature (DVS >= DVSEND)
Side Effects
- Emits crop_emerged signal on emergence.
- Emits crop_finish signal at maturity if end type matches.
Notes
Caps DVS at stage boundary values.
Raises:
-
PCSEError–If STAGE undefined.
Source code in src/diffwofost/physical_models/crop/phenology.py
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | |
diffwofost.physical_models.crop.partitioning.DVS_Partitioning
Bases: _BaseDVSPartitioning
Class for assimilate partitioning based on development stage (DVS).
DVS_Partitioning calculates the partitioning of the assimilates to roots,
stems, leaves and storage organs using fixed partitioning tables as a
function of crop development stage. The available assimilates are first
split into below-ground and aboveground using the values in FRTB. In a
second stage they are split into leaves (FLTB), stems (FSTB) and storage
organs (FOTB).
Since the partitioning fractions are derived from the state variable DVS they are regarded state variables as well.
Simulation parameters (To be provided in cropdata dictionary):
| Name | Description | Type | Unit |
|---|---|---|---|
| FRTB | Partitioning to roots as a function of development stage | TCr | - |
| FSTB | Partitioning to stems as a function of development stage | TCr | - |
| FLTB | Partitioning to leaves as a function of development stage | TCr | - |
| FOTB | Partitioning to storage organs as a function of development stage | TCr | - |
State variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| FR | Fraction partitioned to roots | Y | - |
| FS | Fraction partitioned to stems | Y | - |
| FL | Fraction partitioned to leaves | Y | - |
| FO | Fraction partitioned to storage organs | Y | - |
| PF | Partitioning factors packed in tuple | N | - |
Rate variables
None
External dependencies:
| Name | Description | Provided by | Unit |
|---|---|---|---|
| DVS | Crop development stage | DVS_Phenology | - |
Outputs
| Name | Description | Pbl | Unit |
|---|---|---|---|
| FR | Fraction partitioned to roots | Y | - |
| FL | Fraction partitioned to leaves | Y | - |
| FS | Fraction partitioned to stems | Y | - |
| FO | Fraction partitioned to storage organs | Y | - |
Gradient mapping (which parameters have a gradient):
| Output | Parameters influencing it |
|---|---|
| FR | FRTB, DVS |
| FL | FLTB, DVS |
| FS | FSTB, DVS |
| FO | FOTB, DVS |
Exceptions raised
A PartitioningError is raised if the partitioning coefficients to leaves, stems and storage organs on a given day do not add up to 1.
Methods:
-
initialize–Initialize the DVS_Partitioning simulation object.
-
integrate–Update partitioning factors based on development stage (DVS).
-
calc_rates–Return partitioning factors based on current DVS.
initialize
Initialize the DVS_Partitioning simulation object.
Parameters:
-
day–Start date of the simulation.
-
kiosk(VariableKiosk) –Variable kiosk of this PCSE instance.
-
parvalues(ParameterProvider) –Object providing parameters as key/value pairs.
-
shape(tuple | Size | None, default:None) –Target shape for the state and rate variables.
Source code in src/diffwofost/physical_models/crop/partitioning.py
integrate
calc_rates
Return partitioning factors based on current DVS.
Rate calculation does nothing for partitioning as it is a derived state.
diffwofost.physical_models.crop.assimilation.WOFOST72_Assimilation
Bases: SimulationObject
Class implementing a WOFOST/SUCROS style assimilation routine.
WOFOST calculates the daily gross CO2 assimilation rate of a crop from the absorbed radiation and the photosynthesis-light response curve of individual leaves. This response is dependent on temperature and leaf age. The absorbed radiation is calculated from the total incoming radiation and the leaf area. Daily gross CO2 assimilation is obtained by integrating the assimilation rates over the leaf layers and over the day.
Simulation parameters (provide in cropdata dictionary)
| Name | Description | Type | Unit |
|---|---|---|---|
| AMAXTB | Max. leaf CO2 assimilation rate as function of DVS | TCr | kg CO2 ha⁻¹ leaf h⁻¹ |
| EFFTB | Light use effic. single leaf as a function of daily mean temperature | TCr | kg CO2 ha⁻¹ h⁻¹ /(J m⁻² s⁻¹) |
| KDIFTB | Extinction coefficient for diffuse visible light as function of DVS | TCr | - |
| TMPFTB | Reduction factor on AMAX as function of daily mean temperature | TCr | - |
| TMNFTB | Reduction factor on AMAX as function of daily minimum temperature | TCr | - |
Rate variables
This class returns the potential gross assimilation rate 'PGASS'
directly from the __call__() method, but also includes it as a rate variable.
| Name | Description | Pbl | Unit |
|---|---|---|---|
| PGASS | Potential gross assimilation | Y | kg CH2O ha⁻¹ d⁻¹ |
External dependencies
| Name | Description | Provided by | Unit |
|---|---|---|---|
| DVS | Crop development stage | DVS_Phenology | - |
| LAI | Leaf area index | Leaf_dynamics | - |
Weather inputs used
| Name | Description | Unit |
|---|---|---|
| IRRAD | Daily shortwave radiation | J m⁻² d⁻¹ |
| DTEMP | Daily mean temperature | °C |
| TMIN | Daily minimum temperature | °C |
| LAT | Latitude | degrees |
Outputs
| Name | Description | Pbl | Unit |
|---|---|---|---|
| PGASS | Potential gross assimilation | Y | kg CH2O ha⁻¹ d⁻¹ |
Gradient mapping (which parameters have a gradient):
| Output | Parameters influencing it |
|---|---|
| PGASS | AMAXTB, EFFTB, KDIFTB, TMPFTB, TMNFTB |
Methods:
-
initialize–Initialize the assimilation module.
-
calc_rates–Compute the potential gross assimilation rate (PGASS).
-
__call__–Calculate and return the potential gross assimilation rate (PGASS).
-
integrate–No state variables to integrate for this module.
Attributes:
initialize
initialize(day: date, kiosk: VariableKiosk, parvalues: ParameterProvider, shape: tuple | Size | None = None) -> None
Initialize the assimilation module.
Source code in src/diffwofost/physical_models/crop/assimilation.py
calc_rates
Compute the potential gross assimilation rate (PGASS).
Source code in src/diffwofost/physical_models/crop/assimilation.py
__call__
Calculate and return the potential gross assimilation rate (PGASS).
integrate
diffwofost.physical_models.crop.leaf_dynamics.WOFOST_Leaf_Dynamics
Bases: SimulationObject
Leaf dynamics for the WOFOST crop model.
Implementation of biomass partitioning to leaves, growth and senenscence
of leaves. WOFOST keeps track of the biomass that has been partitioned to
the leaves for each day (variable LV), which is called a leaf class).
For each leaf class the leaf age (variable 'LVAGE') and specific leaf area
(variable SLA) are also registered. Total living leaf biomass is
calculated by summing the biomass values for all leaf classes. Similarly,
leaf area is calculated by summing leaf biomass times specific leaf area
(LV * SLA).
Senescense of the leaves can occur as a result of physiological age, drought stress or self-shading.
Simulation parameters (provide in cropdata dictionary)
| Name | Description | Type | Unit |
|---|---|---|---|
| RGRLAI | Maximum relative increase in LAI. | SCr | ha ha⁻¹ d⁻¹ |
| SPAN | Life span of leaves growing at 35 Celsius | SCr | d |
| TBASE | Lower threshold temp. for ageing of leaves | SCr | C |
| PERDL | Max. relative death rate of leaves due to water stress | SCr | |
| TDWI | Initial total crop dry weight | SCr | kg ha⁻¹ |
| KDIFTB | Extinction coefficient for diffuse visible light as function of DVS | TCr | |
| SLATB | Specific leaf area as a function of DVS | TCr | ha kg⁻¹ |
State variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| LV | Leaf biomass per leaf class | N | kg ha⁻¹ |
| SLA | Specific leaf area per leaf class | N | ha kg⁻¹ |
| LVAGE | Leaf age per leaf class | N | d |
| LVSUM | Sum of LV | N | kg ha⁻¹ |
| LAIEM | LAI at emergence | N | - |
| LASUM | Total leaf area as sum of LV*SLA, not including stem and pod area | N | - |
| LAIEXP | LAI value under theoretical exponential growth | N | - |
| LAIMAX | Maximum LAI reached during growth cycle | N | - |
| LAI | Leaf area index, including stem and pod area | Y | - |
| WLV | Dry weight of living leaves | Y | kg ha⁻¹ |
| DWLV | Dry weight of dead leaves | N | kg ha⁻¹ |
| TWLV | Dry weight of total leaves (living + dead) | Y | kg ha⁻¹ |
Rate variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| GRLV | Growth rate leaves | N | kg ha⁻¹ d⁻¹ |
| DSLV1 | Death rate leaves due to water stress | N | kg ha⁻¹ d⁻¹ |
| DSLV2 | Death rate leaves due to self-shading | N | kg ha⁻¹ d⁻¹ |
| DSLV3 | Death rate leaves due to frost kill | N | kg ha⁻¹ d⁻¹ |
| DSLV | Maximum of DSLV1, DSLV2, DSLV3 | N | kg ha⁻¹ d⁻¹ |
| DALV | Death rate leaves due to aging | N | kg ha⁻¹ d⁻¹ |
| DRLV | Death rate leaves as a combination of DSLV and DALV | N | kg ha⁻¹ d⁻¹ |
| SLAT | Specific leaf area for current time step, adjusted for source/sink limited leaf expansion rate | N | ha kg⁻¹ |
| FYSAGE | Increase in physiological leaf age | N | - |
| GLAIEX | Sink-limited leaf expansion rate (exponential curve) | N | ha ha⁻¹ d⁻¹ |
| GLASOL | Source-limited leaf expansion rate (biomass increase) | N | ha ha⁻¹ d⁻¹ |
External dependencies
| Name | Description | Provided by | Unit |
|---|---|---|---|
| DVS | Crop development stage | DVS_Phenology | - |
| FL | Fraction biomass to leaves | DVS_Partitioning | - |
| FR | Fraction biomass to roots | DVS_Partitioning | - |
| SAI | Stem area index | WOFOST_Stem_Dynamics | - |
| PAI | Pod area index | WOFOST_Storage_Organ_Dynamics | - |
| TRA | Transpiration rate | Evapotranspiration | cm day⁻¹ ? |
| TRAMX | Maximum transpiration rate | Evapotranspiration | cm day⁻¹ ? |
| ADMI | Above-ground dry matter increase | CropSimulation | kg ha⁻¹ d⁻¹ |
| RFTRA | Reduction factor for transpiration (water & oxygen) | Y | - |
| RF_FROST | Reduction factor frost kill | FROSTOL (optional) | - |
Outputs
| Name | Description | Pbl | Unit |
|---|---|---|---|
| LAI | Leaf area index, including stem and pod area | Y | - |
| TWLV | Dry weight of total leaves (living + dead) | Y | kg ha⁻¹ |
Gradient mapping (which parameters have a gradient):
| Output | Parameters influencing it |
|---|---|
| LAI | TDWI, SPAN, RGRLAI, TBASE, KDIFTB, SLATB |
| TWLV | TDWI, PERDL |
[!NOTE] Notice that the following gradients are zero: - ∂SPAN/∂TWLV - ∂PERDL/∂TWLV - ∂KDIFTB/∂LAI
Methods:
-
initialize–Initialize the WOFOST_Leaf_Dynamics simulation object.
-
calc_rates–Calculate the rates of change for the leaf dynamics.
-
integrate–Integrate the leaf dynamics state variables.
Attributes:
initialize
initialize(day: date, kiosk: VariableKiosk, parvalues: ParameterProvider, shape: tuple | Size | None = None) -> None
Initialize the WOFOST_Leaf_Dynamics simulation object.
Parameters:
-
day(date) –The starting date of the simulation.
-
kiosk(VariableKiosk) –A container for registering and publishing (internal and external) state variables. See PCSE documentation for details.
-
parvalues(ParameterProvider) –A dictionary-like container holding all parameter sets (crop, soil, site) as key/value. The values are arrays or scalars. See PCSE documentation for details.
-
shape(tuple | Size | None, default:None) –Target shape for the state and rate variables.
Source code in src/diffwofost/physical_models/crop/leaf_dynamics.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
calc_rates
Calculate the rates of change for the leaf dynamics.
Parameters:
-
day(date) –The current date of the simulation.
-
drv(WeatherDataContainer) –A dictionary-like container holding weather data elements as key/value. The values are arrays or scalars. See PCSE documentation for details.
Source code in src/diffwofost/physical_models/crop/leaf_dynamics.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
integrate
Integrate the leaf dynamics state variables.
Parameters:
-
day(date) –The current date of the simulation.
-
delt(float, default:1.0) –The time step for integration. Defaults to 1.0.
Source code in src/diffwofost/physical_models/crop/leaf_dynamics.py
diffwofost.physical_models.crop.root_dynamics.WOFOST_Root_Dynamics
Bases: SimulationObject
Root biomass dynamics and rooting depth.
Root growth and root biomass dynamics in WOFOST are separate processes, with the only exception that root growth stops when no more biomass is sent to the root system.
Root biomass increase results from the assimilates partitioned to
the root system. Root death is defined as the current root biomass
multiplied by a relative death rate (RDRRTB). The latter as a function
of the development stage (DVS).
Increase in root depth is a simple linear expansion over time until the
maximum rooting depth (RDM) is reached.
Simulation parameters
| Name | Description | Type | Unit |
|---|---|---|---|
| RDI | Initial rooting depth | SCr | cm |
| RRI | Daily increase in rooting depth | SCr | cm day⁻¹ |
| RDMCR | Maximum rooting depth of the crop | SCR | cm |
| RDMSOL | Maximum rooting depth of the soil | SSo | cm |
| TDWI | Initial total crop dry weight | SCr | kg ha⁻¹ |
| IAIRDU | Presence of air ducts in the root (1) or not (0) | SCr | - |
| RDRRTB | Relative death rate of roots as a function of development stage | TCr | - |
State variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| RD | Current rooting depth | Y | cm |
| RDM | Maximum attainable rooting depth at the minimum of the soil and crop maximum rooting depth | N | cm |
| WRT | Weight of living roots | Y | kg ha⁻¹ |
| DWRT | Weight of dead roots | N | kg ha⁻¹ |
| TWRT | Total weight of roots | Y | kg ha⁻¹ |
Rate variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| RR | Growth rate root depth | N | cm |
| GRRT | Growth rate root biomass | N | kg ha⁻¹ d⁻¹ |
| DRRT | Death rate root biomass | N | kg ha⁻¹ d⁻¹ |
| GWRT | Net change in root biomass | N | kg ha⁻¹ d⁻¹ |
Signals send or handled
None
External dependencies:
| Name | Description | Provided by | Unit |
|---|---|---|---|
| DVS | Crop development stage | DVS_Phenology | - |
| DMI | Total dry matter increase | CropSimulation | kg ha⁻¹ d⁻¹ |
| FR | Fraction biomass to roots | DVS_Partitioning | - |
Outputs:
| Name | Description | Provided by | Unit |
|---|---|---|---|
| RD | Current rooting depth | Y | cm |
| TWRT | Total weight of roots | Y | kg ha⁻¹ |
Gradient mapping (which parameters have a gradient):
| Output | Parameters influencing it |
|---|---|
| RD | RDI, RRI, RDMCR, RDMSOL |
| TWRT | TDWI, RDRRTB |
[!NOTE] Notice that the gradient ∂TWRT/∂RDRRTB is zero.
IMPORTANT NOTICE
Currently root development is linear and depends only on the fraction of assimilates send to the roots (FR) and not on the amount of assimilates itself. This means that roots also grow through the winter when there is no assimilation due to low temperatures. There has been a discussion to change this behaviour and make root growth dependent on the assimilates send to the roots: so root growth stops when there are no assimilates available for growth.
Finally, we decided not to change the root model and keep the original WOFOST approach because of the following reasons: - A dry top layer in the soil could create a large drought stress that reduces the assimilates to zero. In this situation the roots would not grow if dependent on the assimilates, while water is available in the zone just below the root zone. Therefore a dependency on the amount of assimilates could create model instability in dry conditions (e.g. Southern-Mediterranean, etc.). - Other solutions to alleviate the problem above were explored: only put this limitation after a certain development stage, putting a dependency on soil moisture levels in the unrooted soil compartment. All these solutions were found to introduce arbitrary parameters that have no clear explanation. Therefore all proposed solutions were discarded.
We conclude that our current knowledge on root development is insufficient to propose a better and more biophysical approach to root development in WOFOST.
Methods:
-
initialize–Initialize the model.
-
calc_rates–Calculate the rates of change of the state variables.
-
integrate–Integrate the state variables using the rates of change.
Attributes:
initialize
initialize(day: date, kiosk: VariableKiosk, parvalues: ParameterProvider, shape: tuple | Size | None = None) -> None
Initialize the model.
Parameters:
-
day(date) –The starting date of the simulation.
-
kiosk(VariableKiosk) –A container for registering and publishing (internal and external) state variables. See PCSE documentation for details.
-
parvalues(ParameterProvider) –A dictionary-like container holding all parameter sets (crop, soil, site) as key/value. The values are arrays or scalars. See PCSE documentation for details.
-
shape(tuple | Size | None, default:None) –Target shape for the state and rate variables.
Source code in src/diffwofost/physical_models/crop/root_dynamics.py
calc_rates
Calculate the rates of change of the state variables.
Parameters:
-
day(date, default:None) –The current date of the simulation.
-
drv(WeatherDataContainer, default:None) –A dictionary-like container holding weather data elements as key/value. The values are arrays or scalars. See PCSE documentation for details.
Source code in src/diffwofost/physical_models/crop/root_dynamics.py
integrate
Integrate the state variables using the rates of change.
Parameters:
-
day(date, default:None) –The current date of the simulation.
-
delt(float, default:1.0) –The time step for integration. Defaults to 1.0.
Source code in src/diffwofost/physical_models/crop/root_dynamics.py
diffwofost.physical_models.crop.storage_organ_dynamics.WOFOST_Storage_Organ_Dynamics
Bases: SimulationObject
Implementation of storage organ dynamics.
Storage organs are the most simple component of the plant in WOFOST and consist of a static pool of biomass. Growth of the storage organs is the result of assimilate partitioning. Death of storage organs is not implemented and the corresponding rate variable (DRSO) is always set to zero.
Pods are green elements of the plant canopy and can as such contribute to the total photosynthetic active area. This is expressed as the Pod Area Index which is obtained by multiplying pod biomass with a fixed Specific Pod Area (SPA).
Simulation parameters
| Name | Description | Type | Unit | |------|===============================================|========|=============| | TDWI | Initial total crop dry weight | SCr | kg ha⁻¹ | | SPA | Specific Pod Area | SCr | ha kg⁻¹ |
State variables
| Name | Description | Pbl | Unit | |------|==================================================|======|=============| | PAI | Pod Area Index | Y | - | | WSO | Weight of living storage organs | Y | kg ha⁻¹ | | DWSO | Weight of dead storage organs | N | kg ha⁻¹ | | TWSO | Total weight of storage organs | Y | kg ha⁻¹ |
Rate variables
| Name | Description | Pbl | Unit | |------|==================================================|======|=============| | GRSO | Growth rate storage organs | N | kg ha⁻¹ d⁻¹ | | DRSO | Death rate storage organs | N | kg ha⁻¹ d⁻¹ | | GWSO | Net change in storage organ biomass | N | kg ha⁻¹ d⁻¹ |
Signals send or handled
None
External dependencies
| Name | Description | Provided by | Unit | |------|====================================|=====================|=============| | ADMI | Above-ground dry matter increase | CropSimulation | kg ha⁻¹ d⁻¹ | | FO | Fraction biomass to storage organs | DVS_Partitioning | - | | FR | Fraction biomass to roots | DVS_Partitioning | - |
Outputs:
| Name | Description | Provided by | Unit |
|---|---|---|---|
| PAI | Pod Area Index | Y | - |
| TWSO | Total weight storage organs | Y | kg ha⁻¹ |
| WSO | Weight living storage organs | Y | kg ha⁻¹ |
Gradient mapping (which parameters have a gradient):
| Output | Parameters influencing it |
|---|---|
| PAI | SPA |
| TWSO | TDWI |
| WSO | TDWI |
Methods:
-
initialize–Initialize the storage organ dynamics model.
-
calc_rates–Calculate the rates of change of the state variables.
-
integrate–Integrate the state variables.
Attributes:
initialize
initialize(day: date, kiosk: VariableKiosk, parvalues: ParameterProvider, shape: tuple | Size | None = None) -> None
Initialize the storage organ dynamics model.
Parameters:
-
day(date) –The starting date of the simulation.
-
kiosk(VariableKiosk) –A container for registering and publishing (internal and external) state variables. See PCSE documentation for details.
-
parvalues(ParameterProvider) –A dictionary-like container holding all parameter sets (crop, soil, site) as key/value. The values are arrays or scalars. See PCSE documentation for details.
-
shape(tuple | Size | None, default:None) –Target shape for the state and rate variables.
Source code in src/diffwofost/physical_models/crop/storage_organ_dynamics.py
calc_rates
Calculate the rates of change of the state variables.
Parameters:
-
day(date, default:None) –The current date of the simulation.
-
drv(WeatherDataContainer, default:None) –A dictionary-like container holding weather data elements as key/value.
Source code in src/diffwofost/physical_models/crop/storage_organ_dynamics.py
integrate
Integrate the state variables.
Parameters:
-
day(date, default:None) –The current date of the simulation.
-
delt(float, default:1.0) –The time step for integration. Defaults to 1.0.
Source code in src/diffwofost/physical_models/crop/storage_organ_dynamics.py
diffwofost.physical_models.crop.respiration.WOFOST_Maintenance_Respiration
Bases: SimulationObject
Maintenance respiration in WOFOST.
WOFOST calculates the maintenance respiration as proportional to the dry
weights of the plant organs to be maintained, where each plant organ can be
assigned a different maintenance coefficient. Multiplying organ weight
with the maintenance coeffients yields the relative maintenance respiration
(RMRES) which is than corrected for senescence (parameter RFSETB). Finally,
the actual maintenance respiration rate is calculated using the daily mean
temperature, assuming a relative increase for each 10 degrees increase
in temperature as defined by Q10.
Simulation parameters (provide in cropdata dictionary)
| Name | Description | Type | Unit |
|---|---|---|---|
| Q10 | Relative increase in maintenance respiration rate with | SCr | - |
| each 10 degrees increase in temperature | - | ||
| RMR | Relative maintenance respiration rate for roots | SCr | kg CH₂O kg⁻¹ d⁻¹ |
| RMS | Relative maintenance respiration rate for stems | SCr | kg CH₂O kg⁻¹ d⁻¹ |
| RML | Relative maintenance respiration rate for leaves | SCr | kg CH₂O kg⁻¹ d⁻¹ |
| RMO | Relative maintenance respiration rate for storage organs | SCr | kg CH₂O kg⁻¹ d⁻¹ |
| RFSETB | Reduction factor for senescence | TCr | - |
Rate variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| PMRES | Potential maintenance respiration rate | N | kg CH₂O ha⁻¹ d⁻¹ |
Signals send or handled
None
External dependencies
| Name | Description | Provided by | Unit |
|---|---|---|---|
| DVS | Crop development stage | DVS_Phenology | - |
| WRT | Dry weight of living roots | WOFOST_Root_Dynamics | kg ha⁻¹ |
| WST | Dry weight of living stems | WOFOST_Stem_Dynamics | kg ha⁻¹ |
| WLV | Dry weight of living leaves | WOFOST_Leaf_Dynamics | kg ha⁻¹ |
| WSO | Dry weight of living storage organs | WOFOST_Storage_Organ_Dynamics | kg ha⁻¹ |
Outputs
| Name | Description | Pbl | Unit |
|---|---|---|---|
| PMRES | Potential maintenance respiration rate | N | kg CH₂O ha⁻¹ d⁻¹ |
Gradient mapping (which parameters have a gradient):
| Output | Parameters influencing it |
|---|---|
| PMRES | Q10, RMR, RML, RMS, RMO, RFSETB |
Methods:
-
initialize–Initialize the maintenance respiration module.
-
calc_rates–Calculate maintenance respiration rates.
-
__call__–Calculate and return maintenance respiration (PMRES).
-
integrate–No state variables to integrate for this module.
Attributes:
initialize
initialize(day: date, kiosk: VariableKiosk, parvalues: ParameterProvider, shape: tuple | None = None)
Initialize the maintenance respiration module.
Parameters:
-
day(date) –Start date of the simulation
-
kiosk(VariableKiosk) –Variable kiosk of this PCSE instance
-
parvalues(ParameterProvider) –ParameterProvider object providing parameters as key/value pairs
-
shape(tuple | None, default:None) –Shape of the parameters tensors (optional)
Source code in src/diffwofost/physical_models/crop/respiration.py
calc_rates
Calculate maintenance respiration rates.
Parameters:
-
day(date) –Current date
-
drv(WeatherDataContainer) –Weather data for the current day
Source code in src/diffwofost/physical_models/crop/respiration.py
__call__
Calculate and return maintenance respiration (PMRES).
diffwofost.physical_models.crop.evapotranspiration.Evapotranspiration
Bases: _BaseEvapotranspirationNonLayered
Potential evaporation (water and soil) rates and crop transpiration rate.
Simulation parameters
| Name | Description | Type | Unit |
|---|---|---|---|
| CFET | Correction factor for potential transpiration rate | SCr | - |
| DEPNR | Dependency number for crop sensitivity to soil moisture stress. | SCr | - |
| KDIFTB | Extinction coefficient for diffuse visible light vs DVS | TCr | - |
| IAIRDU | Switch airducts on (1) or off (0) | SCr | - |
| IOX | Switch oxygen stress on (1) or off (0) | SCr | - |
| CRAIRC | Critical air content for root aeration | SSo | - |
| SM0 | Soil porosity | SSo | - |
| SMW | Volumetric soil moisture at wilting point | SSo | - |
| SMFCF | Volumetric soil moisture at field capacity | SSo | - |
State variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| IDWST | Number of days with water stress | N | - |
| IDOST | Number of days with oxygen stress | N | - |
Rate variables
| Name | Description | Pbl | Unit |
|---|---|---|---|
| EVWMX | Max evaporation rate from open water surface | Y | cm day⁻¹ |
| EVSMX | Max evaporation rate from wet soil surface | Y | cm day⁻¹ |
| TRAMX | Max transpiration rate from canopy | Y | cm day⁻¹ |
| TRA | Actual transpiration rate from canopy | Y | cm day⁻¹ |
| IDOS | Indicates oxygen stress on this day (True | False) | N |
| IDWS | Indicates water stress on this day (True | False) | N |
| RFWS | Reduction factor for water stress | N | - |
| RFOS | Reduction factor for oxygen stress | N | - |
| RFTRA | Combined reduction factor for transpiration | Y | - |
External dependencies
| Name | Description | Provided by | Unit |
|---|---|---|---|
| DVS | Crop development stage | Phenology | - |
| LAI | Leaf area index | Leaf dynamics | - |
| SM | Volumetric soil moisture content | Waterbalance | - |
Outputs
| Name | Description | Pbl | Unit |
|---|---|---|---|
| TRA | Actual transpiration rate from canopy | Y | cm day⁻¹ |
| TRAMX | Max transpiration rate from canopy | Y | cm day⁻¹ |
| EVWMX | Max evaporation rate from open water surface | Y | cm day⁻¹ |
| EVSMX | Max evaporation rate from wet soil surface | Y | cm day⁻¹ |
| RFTRA | Combined reduction factor for transpiration | Y | - |
Gradient mapping (which parameters have a gradient):
| Output | Parameters influencing it |
|---|---|
| EVWMX | KDIFTB |
| EVSMX | KDIFTB |
| TRAMX | CFET, KDIFTB |
| TRA | CFET, KDIFTB, DEPNR, SMFCF, SMW, CRAIRC, SM0 |
| RFTRA | CFET, DEPNR, SMFCF, SMW, CRAIRC, SM0 |
Methods:
-
initialize–Initialize the standard evapotranspiration module (no CO2 effects).
initialize
initialize(day: date, kiosk: VariableKiosk, parvalues: ParameterProvider, shape: tuple | None = None) -> None
Initialize the standard evapotranspiration module (no CO2 effects).
Parameters:
-
day(date) –The starting date of the simulation.
-
kiosk(VariableKiosk) –A container for registering and publishing (internal and external) state variables. See PCSE documentation for details.
-
parvalues(ParameterProvider) –A dictionary-like container holding all parameter sets (crop, soil, site) as key/value. The values are arrays or scalars. See PCSE documentation for details.
-
shape(tuple | Size | None, default:None) –Target shape for the state and rate variables.
Source code in src/diffwofost/physical_models/crop/evapotranspiration.py
Utility (under development)
diffwofost.physical_models.config.Configuration
dataclass
Configuration(CROP: type[SimulationObject], SOIL: type[SimulationObject] | None = None, AGROMANAGEMENT: type[AncillaryObject] = AgroManager, OUTPUT_VARS: list = list(), SUMMARY_OUTPUT_VARS: list = list(), TERMINAL_OUTPUT_VARS: list = list(), OUTPUT_INTERVAL: str = 'daily', OUTPUT_INTERVAL_DAYS: int = 1, OUTPUT_WEEKDAY: int = 0, model_config_file: str | Path | None = None, description: str | None = None)
Class to store model configuration from a PCSE configuration files.
Methods:
-
from_pcse_config_file–Load the model configuration from a PCSE configuration file.
-
update_output_variable_lists–Updates the lists of output variables that are defined in the configuration file.
from_pcse_config_file
classmethod
Load the model configuration from a PCSE configuration file.
Parameters:
-
filename(str | Path) –Path to the configuraiton file. The path is first interpreted with respect to the current working directory and, if not found, it will then be interpreted with respect to the
conffolder in the PCSE package.
Returns:
-
Configuration(Self) –Model configuration instance
Raises:
-
FileNotFoundError–if the configuraiton file does not exist
-
RuntimeError–if parsing the configuration file fails
Source code in src/diffwofost/physical_models/config.py
update_output_variable_lists
update_output_variable_lists(output_vars: str | list | tuple | set | None = None, summary_vars: str | list | tuple | set | None = None, terminal_vars: str | list | tuple | set | None = None)
Updates the lists of output variables that are defined in the configuration file.
This is useful because sometimes you want the flexibility to get access to an additional model variable which is not in the standard list of variables defined in the model configuration file. The more elegant way is to define your own configuration file, but this adds some flexibility particularly for use in jupyter notebooks and exploratory analysis.
Note that there is a different behaviour given the type of the variable provided. List and string inputs will extend the list of variables, while set/tuple inputs will replace the current list.
Parameters:
-
output_vars(str | list | tuple | set | None, default:None) –the variable names to add/replace for the OUTPUT_VARS configuration variable
-
summary_vars(str | list | tuple | set | None, default:None) –the variable names to add/replace for the SUMMARY_OUTPUT_VARS configuration variable
-
terminal_vars(str | list | tuple | set | None, default:None) –the variable names to add/replace for the TERMINAL_OUTPUT_VARS configuration variable
Raises:
-
TypeError–if the type of the input arguments is not recognized
Source code in src/diffwofost/physical_models/config.py
diffwofost.physical_models.config.ComputeConfig
Central configuration for device and dtype settings.
This class acts as a factory for default configuration settings that are captured by simulation objects upon initialization. This enables precise control over where (device) and how (dtype) each model computation occurs, allowing for multiple models with different configurations to coexist.
Key Concept: Configuration Capture
When a simulation object (e.g., WOFOST_Leaf_Dynamics) is initialized, it
queries ComputeConfig for the current device and dtype. The model captures
and stores these settings for its lifetime. Subsequent changes to
ComputeConfig will only affect newly created objects, leaving existing
ones unchanged.
Default Behavior:
- Device: Defaults to torch.get_default_device()
- Dtype: Defaults to torch.get_default_dtype()
Basic Usage:
>>> from diffwofost.physical_models.config import ComputeConfig
>>> import torch
>>>
>>> # Configure defaults for new models
>>> ComputeConfig.set_device('cuda')
>>> ComputeConfig.set_dtype(torch.float32)
>>>
>>> # Get current defaults
>>> device = ComputeConfig.get_device()
>>> dtype = ComputeConfig.get_dtype()
Creating Models with Different Settings:
Because models capture the configuration at initialization, you can create instances with different settings in the same process:
>>> from diffwofost.physical_models.crop.leaf_dynamics import WOFOST_Leaf_Dynamics
>>>
>>> # Create a model on GPU (float32)
>>> ComputeConfig.set_device('cuda')
>>> ComputeConfig.set_dtype(torch.float32)
>>> model_gpu = WOFOST_Leaf_Dynamics(...)
>>>
>>> # Create a model on CPU (float64)
>>> ComputeConfig.set_device('cpu')
>>> ComputeConfig.set_dtype(torch.float64)
>>> model_cpu = WOFOST_Leaf_Dynamics(...)
>>>
>>> # model_gpu remains on cuda, model_cpu stays on cpu.
Setting the model properties like model.device = torch.device("cpu") or
model.dtype = torch.float64 returns AttributeError. Always use
ComputeConfig.set_device(...) and ComputeConfig.set_dtype(...).
Resetting to Defaults:
>>> ComputeConfig.reset_to_defaults()
Methods:
-
get_device–Get the current device setting.
-
set_device–Set the device to use for tensor operations.
-
get_dtype–Get the current dtype setting.
-
set_dtype–Set the dtype to use for tensor creation.
-
reset_to_defaults–Reset device and dtype to their default values.
get_device
classmethod
Get the current device setting.
Returns:
-
device–torch.device: The current device (cuda or cpu)
set_device
classmethod
Set the device to use for tensor operations.
Parameters:
-
device(str | device) –Device to use ('cuda', 'cpu', or torch.device object)
Example
ComputeConfig.set_device('cuda') ComputeConfig.set_device(torch.device('cpu'))
Source code in src/diffwofost/physical_models/config.py
get_dtype
classmethod
Get the current dtype setting.
Returns:
-
dtype–torch.dtype: The current dtype (e.g., torch.float32, torch.float64)
set_dtype
classmethod
Set the dtype to use for tensor creation.
Parameters:
-
dtype(dtype) –PyTorch dtype (torch.float32, torch.float64, etc.)
Example
ComputeConfig.set_dtype(torch.float32)
Source code in src/diffwofost/physical_models/config.py
reset_to_defaults
classmethod
diffwofost.physical_models.engine.Engine
Engine(parameterprovider, weatherdataprovider, agromanagement, config: str | Path | Configuration)
Bases: Engine
Source code in src/diffwofost/physical_models/engine.py
diffwofost.physical_models.utils.EngineTestHelper
EngineTestHelper(parameterprovider, weatherdataprovider, agromanagement, config, external_states=None)
Bases: Engine
An engine which is purely for running the YAML unit tests.
Source code in src/diffwofost/physical_models/utils.py
Other classes (for developers)
diffwofost.physical_models.base.states_rates.TensorStatesTemplate
Bases: TensorContainer, StatesTemplate
Template for storing state variable values as tensors.
It includes functionality to broadcast state variables to a common shape. See
diffwofost.base.states_rates.TensorContainer and
pcse.base.states_rates.StatesTemplate for details.
Source code in src/diffwofost/physical_models/base/states_rates.py
diffwofost.physical_models.base.states_rates.TensorRatesTemplate
Bases: TensorContainer, RatesTemplate
Template for storing rate variable values as tensors.
It includes functionality to broadcast rate variables to a common shape. See
diffwofost.base.states_rates.TensorContainer and
pcse.base.states_rates.RatesTemplate for details.
Source code in src/diffwofost/physical_models/base/states_rates.py
diffwofost.physical_models.base.states_rates.TensorParamTemplate
Bases: TensorContainer, ParamTemplate
Template for storing parameter values as tensors.
It includes functionality to broadcast parameters to a common shape. See
diffwofost.base.states_rates.TensorContainer and
pcse.base.states_rates.ParamTemplate for details.
Source code in src/diffwofost/physical_models/base/states_rates.py
diffwofost.physical_models.base.states_rates.TensorContainer
Bases: HasTraits
It includes functionality to broadcast variables to a common shape. This common shape can be inferred from the container's tensor and AFGEN variables, or it can be set as an input argument.
Parameters:
-
shape(tuple | Size, default:None) –Shape to which the variables in the container are broadcasted. If given, it should match the shape of all the input variables that already have dimensions. Defaults to None.
-
do_not_broadcast(list, default:None) –Name of the variables that are not broadcasted to the container shape. Defaults to None, which means that all variables are broadcasted.
-
variables(dict, default:{}) –Collection of variables to initialize the container, as key-value pairs.
Attributes:
-
shape–Base shape of the variables in the container.
Source code in src/diffwofost/physical_models/base/states_rates.py
diffwofost.physical_models.traitlets.Tensor
Tensor(default_value=Undefined, allow_none=False, read_only=None, help=None, config=None, dtype=None, **kwargs)
Bases: TraitType
Methods:
-
validate–Validate input object, recasting it into a tensor if possible.
-
from_string–Casting tensor from string is not supported for now.
Source code in src/diffwofost/physical_models/traitlets.py
validate
Validate input object, recasting it into a tensor if possible.