Skip to main content
7 votes

Why do my satellites fall out of orbit?

Start with fewer bodies, can you simulate two masses with a spring or an earth/moon system? Track the total kinetic energy and potential energy of the system to verify that your integrator is (...
MPIchael's user avatar
  • 2,985
5 votes

Speeding up 3 body problem acceleration calculation

Welcome to Scicomp! For all following points, always measure and compare. Don't fall for premature optimization! It is the root of all evil. Is the time you spend on optimizing your code worth your ...
MPIchael's user avatar
  • 2,985
5 votes

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 ...
mmikkelsen's user avatar
5 votes
Accepted

Understanding leapfrog integration algorithm

In the second code the full time stepping is given by three lines in main() ...
user9794's user avatar
  • 465
5 votes

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 ...
Lutz Lehmann's user avatar
  • 6,109
4 votes

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 ...
Lutz Lehmann's user avatar
  • 6,109
4 votes

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 ...
Julian Roth's user avatar
3 votes

How to leverage the GPU for parallel 3-body problem computations

CUDA has an example repository with codes for different use cases. There are samples for dealing with matrix operations like the approach you took above. One of the advanced use cases listed is the ...
MPIchael's user avatar
  • 2,985
3 votes

Redefining velocity field to make it divergence free on the grid level

In finite element simulations, we have similar issues for simulations where the spatial mesh changes, e.g. for adaptive meshes that change between time steps. There you have that the solution from one ...
Julian Roth's user avatar
3 votes

Isolating decaying solutions to nonlinear second-order ode

Eliminating the constants, the approximation close to $x=0$ is $y(x)=\pi+xy'(x)$ with $y'$ nearly constant. Or one could multiply the leading terms with $2x^2y'$ and integrate $$ 2x^2y'y''+2xy'^2-2\...
Lutz Lehmann's user avatar
  • 6,109
3 votes

H(curl) conforming Nédélec-Elements to satisfy div(B)=0

The answer you are looking for is found in the notion of weak divergence. Recalling some basic facts about distributions, we say that a function $u$ has a weak divergence if for any smooth function ...
manifoldcurious's user avatar
2 votes

In level set fluid structure interaction method why can we rewrite the elastic force in this form while there is no shear force?

Notice two things: $\nabla \left(E \left( \left| \nabla \phi \right| \right) \right) = E'(|\nabla\phi|)\nabla \left| \nabla\phi \right|$ $\nabla \left( E' \left( \left| \nabla \phi \right| \right) \...
Sthavishtha Bhopalam's user avatar
2 votes

Redefining velocity field to make it divergence free on the grid level

I'm surprised that this question hasn't received an authoritative answer. I'd like to know an authoritative answer to this question myself. This is my stab at it, which I think works in 3D. In 2D the ...
NNN's user avatar
  • 760
2 votes

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

Seems like you double count when accounting for offset. ...
mmikkelsen's user avatar
2 votes

How to properly compute a differential cross section?

Seems that your electron energy of $E=420~\text{MeV}$ messes angle range upon which you calculate cross-section. If you make it smaller by 2 orders of magnitude, like ...
Agnius Vasiliauskas's user avatar
2 votes

Different Results for Double Pendulum

You should make sure your integration is precise enough. I suggest you use the DOP853 algorithm of solve_ivp, which of higher order, and set tight error tolerances, e.g. rtol=atol=1e-12. Then assess ...
Laurent90's user avatar
  • 1,943
1 vote
Accepted

Exact Riemann Solver for Multi-Component 1D Euler Model

I finally found the solution. In the reference [3] the procedure is very detailed, it was just I did not know that mass fractions (Y) do not change across shocks or rarefactions. They just change ...
ReroDani's user avatar
1 vote

Non-dimensionalizing the Ideal MHD System

It depends on what kind of physics you're interested in, but typically for MHD I tend to normalize the magnetic field energy to match the fluid energy: \begin{gather} e_0 = m_0 n_0 V_0^2\\ P_0 = e_0\\ ...
helloworld922's user avatar
1 vote

Will hashing become vulnerable to quantum computers?

As Wolfgang pointed out, your description seems to conflate hashing with encryption. Hashing produces a small, fixed size value in a given range. The popular SHA256 uses 256 bits. A "secure" ...
Mikael Öhman's user avatar
1 vote
Accepted

Lattice Boltzmann method parallelization

DISCLAIMER: For an in-depth discussion, see Chapter 13.4 in Kr├╝ger, which addresses this in 40+ pages. Here, I merely outline two basic ideas. The core LBM consists of the steps Free stream/...
Dan Doe's user avatar
  • 1,083
1 vote

Precession of Mercury Python simulation

It's quite easy to get the necessary precession for Mercury if you take gravitational and kinematic time dilation/length contraction into account. The Newtonian acceleration vector is: \begin{equation}...
shawn_halayka's user avatar

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