From 72b66f491adcfebdf290a69cb2552695b338a1f6 Mon Sep 17 00:00:00 2001 From: SarahAlidoost Date: Thu, 15 Jan 2026 11:09:07 +0100 Subject: [PATCH 1/8] add Simone to citation --- CITATION.cff | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CITATION.cff b/CITATION.cff index 92a791c..09e3f40 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -19,6 +19,11 @@ authors: email: f.nattino@esciencecenter.nl affiliation: Netherlands eScience Center orcid: 'https://orcid.org/0000-0003-3286-0139' + - given-names: Simone + family-names: Ciarella + email: s.ciarella@esciencecenter.nl + affiliation: Netherlands eScience Center + orcid: 'https://orcid.org/0000-0002-9247-139X' - given-names: Michiel family-names: Kallenberg email: michiel.kallenberg@wur.nl From bcc79d5e971000b50f5deb9cbbc9ea4f12a4e2f5 Mon Sep 17 00:00:00 2001 From: SarahAlidoost Date: Thu, 15 Jan 2026 11:09:25 +0100 Subject: [PATCH 2/8] update docs --- docs/examples.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/examples.md b/docs/examples.md index 9259217..0ce8e3c 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -8,10 +8,13 @@ We provide an example notebook showing optimization of models' parameters with | Model | Open the notebook | Access the source | View the notebook | |---|----|------------|---------------| -| Leaf and Root dynamics| [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)][leaf_colab_link] | [![Access the source code](https://img.shields.io/badge/GitHub_Repository-000.svg?logo=github&labelColor=gray&color=blue)][leaf_source_link] | [![here](https://img.shields.io/badge/View_Notebook-orange.svg?logo=jupyter&labelColor=gray)](./notebooks/optimization.ipynb) | | Phenology | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)][pheno_colab_link] | [![Access the source code](https://img.shields.io/badge/GitHub_Repository-000.svg?logo=github&labelColor=gray&color=blue)][pheno_source_link] | [![here](https://img.shields.io/badge/View_Notebook-orange.svg?logo=jupyter&labelColor=gray)](./notebooks/optimization_phenology.ipynb) | +| Root dynamics| [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)][root_colab_link] | [![Access the source code](https://img.shields.io/badge/GitHub_Repository-000.svg?logo=github&labelColor=gray&color=blue)][root_source_link] | [![here](https://img.shields.io/badge/View_Notebook-orange.svg?logo=jupyter&labelColor=gray)](./notebooks/optimization_root_dynamics.ipynb) | +| Leaf dynamics| [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)][leaf_colab_link] | [![Access the source code](https://img.shields.io/badge/GitHub_Repository-000.svg?logo=github&labelColor=gray&color=blue)][leaf_source_link] | [![here](https://img.shields.io/badge/View_Notebook-orange.svg?logo=jupyter&labelColor=gray)](./notebooks/optimization_leaf_dynamics.ipynb) | + !!! note + When calculating gradients, it is important to ensure that the predicted physical parameters are within realistic bounds regarding the crop and environmental conditions. @@ -22,7 +25,9 @@ We provide an example notebook showing optimization of models' parameters with output w.r.t the parameter will be close to zero, which may not provide useful information for optimization. -[leaf_colab_link]: https://colab.research.google.com/github/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization.ipynb -[leaf_source_link]: https://github.com/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization.ipynb +[leaf_colab_link]: https://colab.research.google.com/github/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization_leaf_dynamics.ipynb +[leaf_source_link]: https://github.com/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization_leaf_dynamics.ipynb +[root_colab_link]: https://colab.research.google.com/github/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization_root_dynamics.ipynb +[root_source_link]: https://github.com/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization_root_dynamics.ipynb [pheno_colab_link]: https://colab.research.google.com/github/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization_phenology.ipynb [pheno_source_link]: https://github.com/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization_phenology.ipynb From 50e3cf5cfad61b4098f9f65fd3d710398f67294b Mon Sep 17 00:00:00 2001 From: SarahAlidoost Date: Fri, 16 Jan 2026 15:19:04 +0100 Subject: [PATCH 3/8] change version --- pyproject.toml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e167d54..570f9e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ license = {file = "LICENSE"} name = "diffwofost" readme = {file = "README.md", content-type = "text/markdown"} requires-python = ">=3.11" -version = "0.2.0" +version = "0.3.0" [project.optional-dependencies] dev = [ @@ -131,7 +131,7 @@ force-single-line = true no-lines-before = ["future","standard-library","third-party","first-party","local-folder"] [tool.bumpversion] -current_version = "0.2.0" +current_version = "0.3.0" [[tool.bumpversion.files]] filename = "src/diffwofost/__init__.py" @@ -141,6 +141,3 @@ filename = "pyproject.toml" [[tool.bumpversion.files]] filename = "CITATION.cff" - -[[tool.bumpversion.files]] -filename = "docs/conf.py" From d828abd197f39dc80bb9dd3aeac25fd4c6dfd0c3 Mon Sep 17 00:00:00 2001 From: SarahAlidoost Date: Fri, 16 Jan 2026 15:19:29 +0100 Subject: [PATCH 4/8] change version --- CITATION.cff | 2 +- src/diffwofost/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 09e3f40..4461d83 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -40,7 +40,7 @@ authors: affiliation: Wageningen University & Research orcid: 'https://orcid.org/0000-0002-5517-6404' date-released: 2025-10-29 -version: "0.2.0" +version: "0.3.0" repository-code: "https://github.com/WUR-AI/diffwofost" keywords: - "wofost" diff --git a/src/diffwofost/__init__.py b/src/diffwofost/__init__.py index 598fa37..ac74761 100644 --- a/src/diffwofost/__init__.py +++ b/src/diffwofost/__init__.py @@ -10,7 +10,7 @@ __author__ = "" __email__ = "" -__version__ = "0.2.0" +__version__ = "0.3.0" __all__ = [ "leaf_dynamics", From fcebe4a6155138e4590083e14e84c435425545c9 Mon Sep 17 00:00:00 2001 From: SarahAlidoost Date: Fri, 16 Jan 2026 15:22:05 +0100 Subject: [PATCH 5/8] add imports to init --- src/diffwofost/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/diffwofost/__init__.py b/src/diffwofost/__init__.py index ac74761..62af93a 100644 --- a/src/diffwofost/__init__.py +++ b/src/diffwofost/__init__.py @@ -5,6 +5,9 @@ from diffwofost.physical_models.crop import leaf_dynamics from diffwofost.physical_models.crop import phenology from diffwofost.physical_models.crop import root_dynamics +from diffwofost.physical_models.crop import assimilation +from diffwofost.physical_models.crop import partitioning + logging.getLogger(__name__).addHandler(logging.NullHandler()) @@ -16,5 +19,7 @@ "leaf_dynamics", "root_dynamics", "phenology", + "assimilation", + "partitioning", "utils", ] From 40b1c952083980faed2b5a6e44d2084f0c542f09 Mon Sep 17 00:00:00 2001 From: SarahAlidoost Date: Fri, 16 Jan 2026 15:59:12 +0100 Subject: [PATCH 6/8] add cpu config to the nbs --- docs/notebooks/optimization_leaf_dynamics.ipynb | 12 ++++++++++++ docs/notebooks/optimization_phenology.ipynb | 12 ++++++++++++ docs/notebooks/optimization_root_dynamics.ipynb | 12 ++++++++++++ 3 files changed, 36 insertions(+) diff --git a/docs/notebooks/optimization_leaf_dynamics.ipynb b/docs/notebooks/optimization_leaf_dynamics.ipynb index 1990dd6..df0cd1c 100644 --- a/docs/notebooks/optimization_leaf_dynamics.ipynb +++ b/docs/notebooks/optimization_leaf_dynamics.ipynb @@ -79,6 +79,18 @@ "from diffwofost.physical_models.utils import get_test_data" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "9c2ca761-22b0-4707-9f55-619f62617d12", + "metadata": {}, + "outputs": [], + "source": [ + "# --- run on CPU ------\n", + "from diffwofost.physical_models.config import ComputeConfig\n", + "ComputeConfig.set_device('cpu')" + ] + }, { "cell_type": "code", "execution_count": 2, diff --git a/docs/notebooks/optimization_phenology.ipynb b/docs/notebooks/optimization_phenology.ipynb index 7b40125..2af66e0 100644 --- a/docs/notebooks/optimization_phenology.ipynb +++ b/docs/notebooks/optimization_phenology.ipynb @@ -73,6 +73,18 @@ "from diffwofost.physical_models.utils import get_test_data" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "8a06565c-139a-4039-92d5-bcfd7bcf8344", + "metadata": {}, + "outputs": [], + "source": [ + "# --- run on CPU ------\n", + "from diffwofost.physical_models.config import ComputeConfig\n", + "ComputeConfig.set_device('cpu')" + ] + }, { "cell_type": "code", "execution_count": 2, diff --git a/docs/notebooks/optimization_root_dynamics.ipynb b/docs/notebooks/optimization_root_dynamics.ipynb index 2923f98..0c22f7d 100644 --- a/docs/notebooks/optimization_root_dynamics.ipynb +++ b/docs/notebooks/optimization_root_dynamics.ipynb @@ -88,6 +88,18 @@ "from diffwofost.physical_models.utils import get_test_data" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "10c6361e-ad31-455f-aed1-b7a282cb793c", + "metadata": {}, + "outputs": [], + "source": [ + "# --- run on CPU ------\n", + "from diffwofost.physical_models.config import ComputeConfig\n", + "ComputeConfig.set_device('cpu')" + ] + }, { "cell_type": "code", "execution_count": 3, From 88ef7db2925e6a43b6bc4a74345800a97b2fca46 Mon Sep 17 00:00:00 2001 From: SarahAlidoost Date: Fri, 16 Jan 2026 16:10:36 +0100 Subject: [PATCH 7/8] update docs --- docs/api_reference.md | 11 ++++++----- docs/examples.md | 38 ++++++++++++++++++++++++++++++++++++++ docs/index.md | 5 ++--- docs/run_model.md | 10 +++++++++- 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/docs/api_reference.md b/docs/api_reference.md index ed8303e..4eff37d 100644 --- a/docs/api_reference.md +++ b/docs/api_reference.md @@ -6,15 +6,16 @@ hide: ## **Crop modules** -::: diffwofost.physical_models.crop.leaf_dynamics.WOFOST_Leaf_Dynamics - -::: diffwofost.physical_models.crop.root_dynamics.WOFOST_Root_Dynamics - ::: diffwofost.physical_models.crop.phenology.DVS_Phenology +::: diffwofost.physical_models.crop.partitioning.DVS_Partitioning + ::: diffwofost.physical_models.crop.assimilation.WOFOST72_Assimilation -::: diffwofost.physical_models.crop.partitioning.DVS_Partitioning +::: diffwofost.physical_models.crop.leaf_dynamics.WOFOST_Leaf_Dynamics + +::: diffwofost.physical_models.crop.root_dynamics.WOFOST_Root_Dynamics + ## **Utility (under development)** diff --git a/docs/examples.md b/docs/examples.md index 0ce8e3c..69729aa 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -25,6 +25,44 @@ We provide an example notebook showing optimization of models' parameters with output w.r.t the parameter will be close to zero, which may not provide useful information for optimization. + +## Computing configuration + +The object `ComputeConfig` provides a central configuration for PyTorch device +and dtype settings across all simulation objects in diffWOFOST. Instead of +setting device and dtype individually for each class, use this central +configuration to apply settings globally. + +**Default Behavior:** + +- **Device**: Automatically defaults to 'cuda' if available, otherwise 'cpu' +- **Dtype**: Defaults to torch.float64 + +**Basic Usage:** + +```python +from diffwofost.physical_models.config import ComputeConfig +import torch +# Set device to CPU +ComputeConfig.set_device('cpu') + +# Or use a torch.device object +ComputeConfig.set_device(torch.device('cuda')) + +# Set dtype to float32 +ComputeConfig.set_dtype(torch.float32) + +# Get current settings +device = ComputeConfig.get_device() # Returns: torch.device('cpu') +dtype = ComputeConfig.get_dtype() # Returns: torch.float32 +``` + +**More info:** + +See the [ComputeConfig API +reference](./api_reference.md#diffwofost.physical_models.config.ComputeConfig) +for more details. + [leaf_colab_link]: https://colab.research.google.com/github/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization_leaf_dynamics.ipynb [leaf_source_link]: https://github.com/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization_leaf_dynamics.ipynb [root_colab_link]: https://colab.research.google.com/github/WUR-AI/diffWOFOST/blob/main/docs/notebooks/optimization_root_dynamics.ipynb diff --git a/docs/index.md b/docs/index.md index 11e5a0f..8065d3a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -106,6 +106,5 @@ The package is structured as follows: ``` !!! note - At the moment only two modules of `leaf_dynamics` and `root_dynamics` are - differentiable w.r.t two parameters of `SPAN` and `TDWI`. But the package is under - continuous development. So make sure that you install the latest version. + At the moment the package is under continuous development. So make sure that + you install the latest version. diff --git a/docs/run_model.md b/docs/run_model.md index 79fe7df..29c884a 100644 --- a/docs/run_model.md +++ b/docs/run_model.md @@ -14,13 +14,21 @@ In a nutshell, we can run a model, for example, `leaf_dynamics` using diffWOFOST ```python from diffwofost.physical_models.utils import EngineTestHelper +from diffwofost.physical_models.config import Configuration +from diffwofost.physical_models.crop.leaf_dynamics import WOFOST_Leaf_Dynamics + +# create config +leaf_dynamics_config = Configuration( + CROP=WOFOST_Leaf_Dynamics, + OUTPUT_VARS=["LAI", "TWLV"], +) # create the model model = EngineTestHelper( crop_parameters_provider, # this provides the crop parameters weather_data_provider, agromanagement_provider, - leaf_dynamics_config_file, # this where the differentiable model is specified + leaf_dynamics_config, # this where the differentiable model is specified external_states, # any external states if needed ) From c0172b38eeb9a7ab034328fc521f6121b5948c15 Mon Sep 17 00:00:00 2001 From: SarahAlidoost Date: Fri, 16 Jan 2026 16:16:01 +0100 Subject: [PATCH 8/8] fix linter errors --- src/diffwofost/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/diffwofost/__init__.py b/src/diffwofost/__init__.py index 62af93a..9f13007 100644 --- a/src/diffwofost/__init__.py +++ b/src/diffwofost/__init__.py @@ -2,12 +2,11 @@ import logging from diffwofost.physical_models import utils +from diffwofost.physical_models.crop import assimilation from diffwofost.physical_models.crop import leaf_dynamics +from diffwofost.physical_models.crop import partitioning from diffwofost.physical_models.crop import phenology from diffwofost.physical_models.crop import root_dynamics -from diffwofost.physical_models.crop import assimilation -from diffwofost.physical_models.crop import partitioning - logging.getLogger(__name__).addHandler(logging.NullHandler())