Tag Info

Time and memory required to diagonalize a 18000 by 18000 matrix using numpy in python

A 20000 by 20000 double-precision complex matrix requires $20000 \times 20000 \times 8 \times 2=6.4 \mbox{gigabytes}$ of RAM. The LAPACK routines ZHEEV that will do the work for you will store the ...
• 18.5k

Solving non-linear partial differential equation numerically: $u_{xx}+u_{yy}=\mathrm{e}^{u}$

You can use something like MethodOfLines.jl to solve your problem. You can modify the following example, something like this ...
• 369
Accepted

Understanding leapfrog integration algorithm

In the second code the full time stepping is given by three lines in main() ...
• 465

Is my differential equation solving code wrong?

The cross product with $H$ acts like a complex unit in the plane that has $H$ as normal, especially if you select $H$ to be a unit vector. Components parallel to $H$ remain unchanged. What you should ...
• 5,489

Rank-1 correction of matrix exponential

There is work on low-rank updates of matrix functions, for instance this one: Beckermann, Bernhard; Kressner, Daniel; Schweitzer, Marcel, Low-rank updates of matrix functions, SIAM J. Matrix Anal. ...
• 11.1k

Understanding leapfrog integration algorithm

The first code is wrong if you have multiple particles that interact. Due to the structure of the loop, the interaction forces with particles at the start of the list are computed with the updated ...
• 5,489

Euler's Method for fast moving particle trajectory

I tried to modify your code as little as possible and include the comments by @lightxbulb. I changed the indices in the time stepping loop and modified $F$ and $B$ so that they are being updated in ...
• 361

• 3,042
Accepted

Issues with Simulating the Orbits of Mars and Earth using MATLAB and Runge-Kutta Method

You accidentally divided by the planet's mass twice. The force exerted by the sun on the planet is $$\vec{F} = -\frac{G M_s m_p}{\|r\|^3} \vec{r}$$ Plugging that in to the equation of motion for the ...
• 2,391
Accepted

Problems solving 2D heat equation using physics-informed neural networks

The one thing that i can notice immediately where it might be going wrong is the use of ReLU Activation function for PINNs. In this problem,we have a double derivative in our loss function (Laplacian)....
• 309
Accepted

Best approach to simulating dynamics on networks

I assume that your networks are sparse (most entries of the adjacency matrix are zero) and irregular (no grids and similar repeating structures). As an example, let’s look at an ODE: $\dot{x} = f(x).$ ...
• 2,022

Need help with the python code: Calculating Madelung constant CsCl crystal structure

Seems like you double count when accounting for offset. ...
• 369
Accepted

finding weak form of nonlinear differential equation for FEM simulation

First notice that $$(k_3 - k_1)\sin(u)\cos(u)(u')^2 + (k_1\cos^2(u) + k_3\sin^2(u))u'' = ((k_1\cos^2(u) + k_3\sin^2(u))u')' + (k_1 - k_3)\sin(u)\cos(u)(u')^2.$$ I choose to rearrange our equation so ...
• 2,054
Accepted

1 dimensional simulation of gravity fails

what is wrong with the simulation ? Your problem is that you are using the Euler method to derive your numerical solution. Although this method is simple to implement, it is inaccurate and unstable. ...
• 136

• 5,489
1 vote

Numerical code to solve LLG is not preserving norm

Your forward Euler method will not preserve the norm. You need to use a different integrator (such as symplectic integrators).
• 617
1 vote

3D turbulent divergence free initial velocity field

One way to make your field divergence free is via the Leray Projection. The underlying idea is to identify that part of your vector field which is non-divergence free, and then subtract that from your ...
• 2,627
1 vote

Good examples of "two is easy, three is hard" in computational sciences

The example that comes to mind is quaternions. I think it is way better to quote the Wikipedia article about quaternions: Hamilton knew that the complex numbers could be interpreted as points in a ...
• 156

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