@mcflugen and I will be at Texas State University this Wed and Thu for a CSDMS Roadshow, hosted by Prof. Todd Swannack in the Department of Biological Sciences (also the U.S. Army Corps of Engineers Integrated Ecological Modeling team).
We’re trying a new approach, where we’ll build a model together with the class, introducing topics like version control, refactoring, packaging, and testing as they’re needed.
Here’s our repository: csdms/roadshow-diffusion. Let us know what you think!
3 Likes
Looks great!
In the inline equation for the FTCS scheme space is oriented as right-to-left:
C^t_{x+1} - 2C^t_x + C^t_{x-1}
but the code later does left- to right- (standard way!)
centered_diff = np.roll(concentration, -1) - 2*concentration + np.roll(concentration, 1)
Might be nice to change the original equation to be in this order too (even though it makes no difference to the result!)?
C^t_{x-1} - 2C^t_x + C^t_{x+1}
Thanks for lending a critical eye to this, @dorchard! I’ll swap the order of the terms in the original equation to make them left-to-right.
I think I’ll have to reorder the terms in the code, as well, though, since np.roll(concentration, -1)
returns an array shifted to the left, which is the C^t_{x+1}
term, right?
Oh that’s a good point- you’re absolutely right. That would make sense.
One other thought is whether there’s an opportunity to discuss numerical corner cases when it comes to divide by zero errors? e.g., what if someone tries to use 0 diffusivity (like a gas at absolute zero)? roadshow-diffusion/roadshow_diffusion/diffusion.py at main · csdms/roadshow-diffusion · GitHub
It’s not exactly necessary in this code but I’m always on the look out for opportunities to talk about correctness, testing, and numerical issues!