Skip to content

Make the Root dynamics differentiable#29

Merged
SarahAlidoost merged 19 commits into
mainfrom
root_dynamics
Sep 29, 2025
Merged

Make the Root dynamics differentiable#29
SarahAlidoost merged 19 commits into
mainfrom
root_dynamics

Conversation

@SarahAlidoost
Copy link
Copy Markdown
Collaborator

relates #8

🔴 this branch is based on #12 , should be merged after that.

Copy link
Copy Markdown
Collaborator

@fnattino fnattino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice @SarahAlidoost, looks great to me! I have just added a couple of minor comments, feel free to include only what makes sense to you and let me know whether anything is unclear!

Comment thread tests/physical_models/crop/test_root_dynamics.py Outdated

# Increase in root biomass
r.GRRT = mask * k.FR * k.DMI
r.DRRT = mask * s.WRT * p.RDRRTB(k.DVS)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the values returned by the Afgen objects (here the call to p.RDRRTB) are not tensors. For the scalar case it probably makes no difference, but it will probably matter when we want to vectorize this (#19).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen that in leaf_dynamics we convert the output of the call to Afgen objects to tensor:

SLA = torch.tensor([params.SLATB(DVS)], dtype=DTYPE)

But a better approach might be to modify pcse.util.Afgen so that it returns a tensor already. We could maybe use one of the functions for piece-wise linear interpolation from here. Anyway, not to be addressed here, it can probably be done as part of #19.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fnattino thanks! You are right. Some of the parameters are not yet fully tensors. This PR is about one parameter: TDWI. The rest should be fixed in the next iteration, not only in #19 but when we revisit this module for the differentiability of other parameters. Note that currently, only TDWI is covered by tests.

Comment thread tests/physical_models/crop/test_root_dynamics.py
Comment thread tests/physical_models/crop/test_root_dynamics.py Outdated
Comment thread tests/physical_models/crop/test_root_dynamics.py Outdated
Comment thread tests/physical_models/crop/test_root_dynamics.py
SarahAlidoost and others added 6 commits September 29, 2025 09:46
Co-authored-by: Francesco Nattino <49899980+fnattino@users.noreply.github.com>
Co-authored-by: Francesco Nattino <49899980+fnattino@users.noreply.github.com>
Co-authored-by: Francesco Nattino <49899980+fnattino@users.noreply.github.com>
@SarahAlidoost SarahAlidoost merged commit 035703a into main Sep 29, 2025
8 of 10 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in DeltaCrop: epic1 and epic2 Sep 29, 2025
@SarahAlidoost SarahAlidoost deleted the root_dynamics branch September 29, 2025 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants