Replies: 3 comments
-
The fast way to do this is to assign the value of the current cell based on the neighbours, like a convolution. For that you can just use a simple If you need to do it the other way around and set neighbour values for some reason, you can use |
Beta Was this translation helpful? Give feedback.
-
This is not something you can (or should) do in DynamicGrids.jl. The concept is the same as cellular automata: everything happens at the same time! then updates are done for the next time-step. If you need an iterative model, just write it using Stencils.jl directly (it does all the windowing here) then you can just extract stencils wherever you like in a loop. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your suggestion. I will try to improve my code based on your recommendations. Once completed, I can upload the implemented code, hoping it will be useful for others. |
Beta Was this translation helpful? Give feedback.
-
I will describe this issue in more detail. Firstly, we have a geographic elevation dataset, which we will convert into flow direction (D8 flow direction). This means that a standard grid cell has eight neighbors. Based on each cell's unique D8, we can determine that the current state of the cell will transfer to one of its eight neighbors. I checked the documentation, and Neighbors seems to be one of the keys to solving this problem. However, I am unsure how to assign a state to a specific neighbor based on the flow direction. I suspect that rules should be constructed for the eight flow directions, and when a flow direction matches a rule, that rule is executed. Below is a simple implementation of my requirement without using this package, but this computation does not seem to be differentiable:
In addition, at each time point, each cell will generate a new state (rainfall generating flow) and combine the input values from other cells in the previous period to construct a new state. I am also unsure how to implement this functionality.
Finally, I have another question about this package: how can we set the computation order of each cell (in some cases, it might need to be determined based on the cumulative flow value of each cell generated by the flow direction)?
Beta Was this translation helpful? Give feedback.
All reactions