Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiscale mapping to other variable name #57

Closed
VEZY opened this issue Mar 20, 2024 · 2 comments
Closed

Multiscale mapping to other variable name #57

VEZY opened this issue Mar 20, 2024 · 2 comments

Comments

@VEZY
Copy link
Member

VEZY commented Mar 20, 2024

Make it possible to map a set of variables from different scales into a scale, but with a different variable name. For example, if we want to take the value of Rm in the organs and pass the vector as input of Rm_organs we would do:

MultiScaleModel(
	model=PlantRm(),
	mapping=[:Rm => ["Leaf", "Internode", "Male", "Female"] => :Rm_organs],
)

This allows to put Rm as output of our model, instead of having to rename it.

Before we had to have this kind of models:

struct PlantRm <: AbstractMaintenance_RespirationModel end

PlantSimEngine.inputs_(::PlantRm) = (Rm=[-Inf],)
PlantSimEngine.outputs_(::PlantRm) = (Rm_plant=-Inf,)

function PlantSimEngine.run!(::PlantRm, models, status, meteo, constants, extra=nothing)
    status.Rm_plant = sum(status.Rm)
end

With this feature we could say that the input Rm from other scales takes another name, so we can use Rm for the output at this scale:

struct PlantRm <: AbstractMaintenance_RespirationModel end

PlantSimEngine.inputs_(::PlantRm) = (Rm_organs=[-Inf],)
PlantSimEngine.outputs_(::PlantRm) = (Rm=-Inf,)

function PlantSimEngine.run!(::PlantRm, models, status, meteo, constants, extra=nothing)
    status.Rm = sum(status.Rm_organs)
end

This is much more consistent and allows to keep the same variable names across scales, e.g. Rm is the respiration maintenance of the given scale, whatever the scale.

@VEZY
Copy link
Member Author

VEZY commented Mar 20, 2024

I read the code quickly, and I think we could do that for MappedVar by setting the var field to the variable that we get from other scales, and the var we put this into as the var we want to put it in, e.g.:

Rm_organs = MappedVar(["Leaf", "Internode", "Male", "Female"], :Rm, [-Inf])

For RefVector, I'm not sure yet. We could add a var field too, but it would stay there in the status then. I don't know if that's good or bad.

@VEZY
Copy link
Member Author

VEZY commented Apr 4, 2024

Closed in the latest work I did in the past couple of weeks. This was not done in a PR unfortunately (this has to change!).

@VEZY VEZY closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant