Closed BrianCollinss closed 5 years ago
@hol430 Hi Drew. By any chance, did you manage to have a look at this? I am working on a photosynthesis model based on a multi-layered canopy. But I am not sure if this works properly and I was not sure what happens if I change it as most of my commits fail to be built. And it seems very important to have the crop architecture simulated correctly. Cheers.
When you say your code is failing to be built, do you mean the code in one of your pull requests, or the code on your local machine which you've written to address this issue?
I don't have any problem compiling the code on my Laptop. But most of the times my code cannot be compiled by Jenkins. You can see my last pull request, for instance. https://github.com/APSIMInitiative/ApsimX/pull/3102
Yeah, there's been an issue with Jenkins over the last few weeks which has caused it to fail to compile sometimes. Not sure what caused it, and to be honest I don't think I've actually fixed it, but the last dozen or so builds don't seem to have been affected by it.
Either way, #3102 compiled fine, but it encountered some runtime errors in the soil nitrogen patchiness validation set located under ApsimX\Tests\Simulation\SoilNitrogenPatch\
:
Growth and tissue turnover resulted in loss of mass balance for roots
If you run this file on your computer you should be able to reproduce the problem.
Thanks @hol430 . And do you have any idea why the number of canopy layers is kept at one?
I have no idea why it's kept at 1, but I've sent @hut104 an email pointing him to this issue. He's muted all github notifications so unfortunately there's no way to get his attention via github.
@byzheng hi Bangyou. Do you have any comment on this issue?
Hi,
I think you may be referring to the code in
///
Hi @hut104
Thanks for the response. And yes, that is the part of the code I was referring to.
I thought each canopy was supposed to have multiple layers. If this is not the case, please ignore what follows. And sorry if I am not making any sense as I am not aware of the idea behind the code.
Otherwise, there are couple of things:
double HeightMetres = Math.Round(Canopies[compNo].Canopy.Height, 5) / 1000.0; double DepthMetres = Math.Round(Canopies[compNo].Canopy.Depth, 5) / 1000.0; double canopyBase = HeightMetres - DepthMetres; if (Array.IndexOf(nodes, HeightMetres) == -1) { nodes[numNodes] = HeightMetres; numNodes = numNodes + 1; } if (Array.IndexOf(nodes, canopyBase) == -1) { nodes[numNodes] = canopyBase; numNodes = numNodes + 1; }
However, this code fails to do the rounding correctly. I think '/1000.0' must be moved inside the 'Math.Round' function or the number of digits should be reduced to 2 (rounding to the closes multiplier of 10), which leads to a rounder crop height that can be compared to previous values.
Moreover, as the number of node is always 1 at the beginning of each day, it creates another node, i.e. second node, and canopy ends up with just two nodes and 1 layer, on all days.
I attach an example where crop reached 900 mm of height and it only has two two nodes and 1 layer. I think 'numNodes' should be initialised once at sowing and then keep growing based on crop height.
The rounding is simply to avoid having thin layers of no consequence affecting the model (e.g. if you have two canopies that are 0.1mm different in height you would have a layer of that thickness at the top. So we use rounding to effectively set a lower limit for canopy layer thickness (and to avoid issues with comparing equality for floats). We start counting each day because numnodes is the number of canopy tops and bottoms. If you always have one canopy every day, and that canopy only has one layer (as most crop models do) then you will always end up with two nodes (top and bottom) for one layer. If you are looking to have a multi-layered canopy, we would need to pass that information to micromet via some sort of more complex type. We haven't implemented this in NextGen because till now no crop has sought to have layered canopies.
Thanks a lot @hut104 . Quite informative.
State variables 'numNodes' and 'numLayers' are always 2 and 1, respectively. I see that in the private method 'DefineLayers' in MicroClimateZone.cs, 'numNodes' starts at 1 on all days. Is this intentional? Should the crop be considered as a single-layered canopy or I am missing some part of the theories?