zalf-rpm / monica

license
Mozilla Public License 2.0
24 stars 10 forks source link

expand the number of setable variables #29

Open ciskoh opened 9 months ago

ciskoh commented 9 months ago

Hi all and thanks for your nice work. I would like to request to expand the number of setable variables, so that we cxan make long term simulations closer to reality by adding mesured values. My variables of interest are:

c/n ratio soil organic carbon AbovegroundBiomass AbovegroundBiomassNContent CropHeight Surface water runoff

Would that be possible? What is the entry point for this in the code? could not find in the core modules how to set values

bergm commented 9 months ago

Hello Matteo,

it's certainly possible to extend the setable variables. The problem is rather if it's easy to do and what the semantics should be. Without checking properly I would guess that setting the c/n ratio and soil organic carbon might not be too complicated, but all the others, except for surface water runoff (where I don't understand what to set there), it looks even more complicated. In the end these output variables are usually aggregated and if you want to set them, you (or sombody who knows) has to decide how to implement the correct semantics. E.g. for above ground biomass you would have to define new biomass for the single organs, but then if you do this you have to make sure that everything depending on that (or the other way around) is adjusted accordingly. I guess what you want to do is data assimilation, what people in our department want to do as well and in that regard there certainly will be put some thought into that in the future. I just don't know the current state of things. But I can ask around. But also for soil organic carbon it might not be as obvious as changing that in a layer means basically that you would change all the organic matter pools Monica has at each organic layer (which might have different c/n ratios as well).

Regarding where to find the setter code, just have a look here: https://github.com/zalf-rpm/monica/blob/master/src/io/build-output.cpp#L976 This is setting the carbamid content in a layer. In the end there is no particular API for that, you just have to do whatever is necessary - which might include adding code at multiple places if it is more complicated as would be the case for data assimilation. That's why there are only the four variables you can change/update right now, because these act directly as the state of soilmoisture, carbamid, no3 and nh4.

I hope this helped a bit, at least for the moment. I'll try to find out what are the plans for data assimilation regarding Monica.

Cheers, Michael

ciskoh commented 7 months ago

Thank you for the answer, that makes things clearer. I will try to implement on my side and provide a PR request if it works.