# Tag Info

10

I have found that I must keep the value of dt near dx or the results become unstable This behavior you have noticed is known as the Courant–Friedrichs–Lewy (CFL) condition. Indeed, there are timestep restrictions that are related to spatial refinement and choice of time integration method. Due to the diffusion term in 13a, the timestep must satisfy an ...

7

Shoutout to Kyle Mandli and Endulum who each contributed to this answer in the comments. First, I took Endulum's suggestion and removed the redundant reshapes. After this change the Fortran version was beating Python on small scale examples, but at scale the Python version was still faster. Then I implemented Kyle Mandli's suggestion and replaced all of the ...

4

Since you are on a uniform $x-y-z$ grid, you are in luck that others have had similar issues before. Specifically, I would suggest that you take a look at HDF5 for a low-level way of storing this kind of data as arrays. But in the end, you want to not just store an array, but actually do something with it: interpolate. For this, a higher-level approach would ...

4

Instead of using 4 levels of nested loops, you can take advantage of Kronecker products to simply your commutator_matrix function to def commutator_matrix(X): id = np.identity(np.shape(X)) return np.kron(np.transpose(X), id) - np.kron(id, X) This is still the transpose of what you want. The function you are looking for is def ...

2

output[i*n + j][k*n + l] = com[k][l] That's your mistake I think -- reversed indices. To compute the matrix $M$ associated to a linear operator $f$ (the way it's usually taught in a linear algebra course), you need to take a basis of the input space $e_1, \dots, e_n$, compute $f(e_J)$ for each $J$, and write its coordinates (wrt a basis of the output space) ...

2

The sampling theorem in the form used (more Nyquist than Shannon) only applies to periodic functions. As your sampling interval has length $1$, this only allows for frequencies that have $1$ as one of their periods, that is, for angular frequencies $2\pi f$ where the cyclic frequency $f$ is an integer. If you use $1/1000$ as spacing between frequencies, then ...

1

As suggested in Kindlmann the curvature of a surface is defined by the relationship between positional changes in the neighborhood of a point placed on the surface and the change in the surface normal. Given a level-set $\Phi(\mathbf{x})$, we consider that the value of the level-set is positive inside the object, negative outside. Hence, we define the ...

1

To repeat the answers you got at your cross-post https://stackoverflow.com/questions/69292456/logistic-growth-curve-using-scipy-is-not-quite-right The logistic curve is rather rigid in its symmetry. Forcing the initial value to be some prescribed constant effectively removes a degree of freedom in the family of curves that are available to the fitting ...

1

I know this is a little bit late, but there's a third party library in Python which solve PDEs using FD, it is called findiff. Check it out.

Only top voted, non community-wiki answers of a minimum length are eligible