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

dimenion error when using nodes #151

Open
noemiversluijs opened this issue Dec 10, 2024 · 1 comment
Open

dimenion error when using nodes #151

noemiversluijs opened this issue Dec 10, 2024 · 1 comment

Comments

@noemiversluijs
Copy link

I'm working in a script that combines example7b_coupling.py and example6d_mapped_xylemflux_.py (script is attached). When trying to plot rx, sx, soil_fluxes, and xylem_fluxes, an error occurs stating that the dimensions of these lists and nodes[] are not the same. However, each time I print nodes, it seems that there are different values in it. Can someone tell me what the values in nodes mean and why this error seems to occur? When running example6d_mapped_xylemflux_.py with one of the example plant modelparameters, the issue does not occur, so it seems to mabye have something to do with my modelparameter setting?

sorghum_1012.txt

@m-giraud
Copy link
Contributor

Dear noemiversluijs,
Thank you for reaching out and well done with adapting the script.

  1. In CPlantBox, plants are made of nodes connected by segments, creating a network with no cycles. Consequently, a plant with N segments will have N+1 nodes. rx is the water potential of the root system, given per node. It should be of shape [N] (with N still the number of nodes). sx is the mean water potential of each soil voxel, taken from the potential at the center of the voxel, it will be as long as there are voxels. soil_fluxes is the plant water uptake summed per voxel (as several root segments can be in the same soil voxel), it is a dictionary where each key is the index of a cell and the values give the net plant water uptake in the voxel (voxels with no roots are not in the dictionary). the nodes array give the 3D coordinate of each nodes, it is of chape [N,3].
  2. CPlantBox is a stochastic models. The realised value of each plant organ parameter will be taken from a normal distribution using the mean and std value given in the parameter file. Moreover, the tropism function (which sets where each new plant segment points to) is also in part random. If you want to have each time the same values, you can send a 'random seed' to the plant object. This way, the random function used within CPlantBox will give the same sequence of random number at each simulation. I added a commented line rs.setSeed(0), you can uncomment it to get this fixed behavior.
  3. In your script, get_nodes is called before the simulation loop. However, each time rs.simulate(dt) is called, the plant grows (unless it has reached its maximum size) and the number of nodes and segments can increase. Therefore, the size of rx obtained at the end of the simulation is longer than the number of nodes stored at the beginning of the simulation. I added in your script a line of code to fix that, and updated the other plots as well.
  4. other remarks: the sanity check r.test() needs to be updated: it throws warnings such as Warning: segment 3071 is not mapped, this will cause problems with coupling!. It mean that for some segments, CPlantBox did not manage to make them fit completelly in the soil space defined (e.g., the z coordinate is at -15.02, inferior to the -15cm max depth of the soil). Contrary to what the code says, it will not cause a problem in the coupling, the root segment is considered to be outside the soil and with neither loose nor gain water. So you can ignore the warning.

here is the updated file:
sorghum_1812.txt

let me know if anything was not clear

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

2 participants