API for the cnp module#
The cnp module contains the class for
managing pools of stoichiometric explicit mass: carbon (C), nitrogen (N), and phosphorus
(P).
Classes:
|
A dataclass representing Carbon (C), Nitrogen (N), and Phosphorus (P) mass. |
Functions:
|
Find the stoichiometries of each microbial functional group. |
- class virtual_ecosystem.models.animal.cnp.CNP(C: float, N: float, P: float)[source]#
A dataclass representing Carbon (C), Nitrogen (N), and Phosphorus (P) mass.
This class features common operations on CNP mass, including arithmetic manipulations, stoichiometric calculations, and ratio/proportion retrieval.
- Variables:
Methods:
from_dict(data)Create a CNP instance from a dictionary.
Calculate the proportion of each element relative to the total CNP mass.
Calculate the Carbon:Nitrogen (C:N) and Carbon:Phosphorus (C:P) ratios.
update(*[, C, N, P])Update C, N, and P values.
Attributes:
Calculate the total combined mass of C, N, and P.
- get_proportions() dict[str, float][source]#
Calculate the proportion of each element relative to the total CNP mass.
If the total mass is zero, proportions are set to zero to avoid division errors.
- get_ratios() dict[str, float][source]#
Calculate the Carbon:Nitrogen (C:N) and Carbon:Phosphorus (C:P) ratios.
TODO: finalize alternative output with jacob
- property total: float#
Calculate the total combined mass of C, N, and P.
- Returns:
The sum of carbon, nitrogen, and phosphorus mass.
- Return type:
- update(*, C: float = 0.0, N: float = 0.0, P: float = 0.0) None[source]#
Update C, N, and P values. Positive values add; negative values subtract.
- Parameters:
C – Amount of carbon to adjust. Defaults to 0.0.
N – Amount of nitrogen to adjust. Defaults to 0.0.
P – Amount of phosphorus to adjust. Defaults to 0.0.
- virtual_ecosystem.models.animal.cnp.find_microbial_stoichiometries(config: CompiledConfiguration) dict[str, dict[str, float]][source]#
Find the stoichiometries of each microbial functional group.
This extracts the soil configuration from the simulation configuration and then compiles a dictionary of CN and CP ratios for each microbial group.
- Parameters:
config – A compiled Virtual Ecosystem configuration instance.
- Returns:
A dictionary containing the carbon to nutrient ratios of each microbial functional group, for both nitrogen and phosphorus [unitless]