Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [computational-physics]

Computational physics is the study and implementation of numerical algorithms to solve problems in physics for which a quantitative theory already exists.

Filter by
Sorted by
Tagged with
34
votes
6answers
4k views

Are there simple ways to numerically solve the time-dependent Schrödinger equation?

I would like to run some simple simulations of scattering of wavepackets off of simple potentials in one dimension. Are there simple ways to numerically solve the one-dimensional TDSE for a single ...
29
votes
16answers
9k views

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

I recently encountered a formulation of the meta-phenomenon: "two is easy, three is hard" (phrased this way by Federico Poloni), which can be described, as follows: When a certain problem is ...
22
votes
5answers
5k views

What language should I use when teaching an undergraduate course in computer programming?

Going to teach students of undergraduate level a course titled Introduction to Computer Programming. I am confused a bit. In Computational Physics scientists use C/C++ or Python or Fortran,CUDA etc.......
14
votes
2answers
274 views

Quality of linear congruential generators for random numbers

I'm doing some simulations of the Langevin equation, for various external forces. Being told that C's rand() from stdlib.h can ...
11
votes
2answers
6k views

How do I plot the surface of a 4D plot?

I am trying to plot the wave function for a particle in a 3D box. This requires me to plot 4 variables: x, y, z axes and the probability density function. The probability density function is: ...
11
votes
1answer
861 views

Why is leapfrog integration symplectic and RK4 not, if the latter is more accurate?

In a system where energy theoretically should be conserved, the most accurate simulation would conserve energy (as well as giving accurate positions, velocities and etc). RK4 is more accurate than ...
10
votes
3answers
1k views

What are the differences between CFD simulations and realistic ocean/atmosphere model simulations?

The field of computational fluid dynamics (CFD) is dedicated to solving the Navier-Stokes equations (or some simplification of them). A subset of CFD, ocean and atmospheric models numerically solve ...
7
votes
4answers
531 views

Introductory book on computational physics [duplicate]

I'm currently working on my MS in CS and have developed an interest in astrophysics. Luckily one of my professors is a astrophysicist and is currently doing research through computational physics and ...
7
votes
1answer
262 views

Why should I renormalize physical variables?

I am working with legacy physical codes and I develop new ones based on the output of them. They all use their own internal normalization of variables (for example all distances are divided by the ...
7
votes
2answers
2k views

Efficiently finding all (x,y,z) points within certain distance of point P

I am using Python, and I have a Pandas dataframe with hundreds of thousands, if not millions, of $(x,y,z)$ coordinates. I am looking to find an efficient method to index the original dataframe so that ...
7
votes
1answer
424 views

Solving a simple Schroedinger equation with Fast Fourier Transforms

While trying to solve a stochastic Gross-Piaevskii equation I have found a problem that can be tracked down to something buggy occuring in the simplest Schrodinger equation possible: $\partial_t \psi ...
7
votes
0answers
459 views

DIIS method to accelerate SCF convergence for stretched geometries

I am implementing from scratch an Hartree-Fock calculation in the STO-3G basis set to perform Born-Oppenheimer molecular dynamics. I have a Restricted Hartree-Fock procedure that can reproduce very ...
6
votes
4answers
201 views

In Matlab, how can I be consistent with units?

I am modeling some aerodynamics equations and am using meters / centimeters, kilograms, and seconds. I've heard that, "matlab doesn't know units". So, how can I make sure that it does? Just ...
6
votes
3answers
2k views

Galerkin method: Test functions vs. Basis functions

I'm a novice to finite element and I'm finding quite hard to find the actual difference between Test function(s) and Basis function(s). I would be glad if somone could explain me that and point out ...
6
votes
1answer
259 views

Putting N hard spheres randomly in given volume

I need to put $N$ spheres with given radius $R$ randomly in a Volume $[-0.5,0.5]^3$, without any overlap of spheres. If I choose values so that all the spheres will occupy ~57% of the total volume, I ...
6
votes
2answers
3k views

Calculating the log-determinant of a large sparse matrix

I need to calculate $\log(\det (\mathbf M_i))$ where the $\mathbf M_i$'s are large sparse matrices, which are real, symmetric and positive semi-definite. I hope to have between $10$ and $100$ of ...
6
votes
1answer
6k views

How do I generate Maxwell-Boltzmann variates using a uniform distribution random number generator?

I am doing a molecular dynamics simulation. I need to assign initial velocities to the atoms. I want to assign the initial velocities which follow the Maxwell-Boltzmann distribution. How do I ...
6
votes
1answer
93 views

Eigenvalue problems with extremely small gaps

I'm interested in numerically diagonalizing a class of structured, symmetric eigenvalue problems with potentially extremely small eigenvalue gaps. The question I have is how to design a numerically ...
6
votes
1answer
169 views

Pressure definition/convergence issues for the Incompressible Navier-Stokes when using a stabilized P1-P1 finite element formulation

I believe this might be a recurring topic, but i have not found a post that directly related to this issue. I come from a finite volume background and my experience is more with predictor-corrector ...
6
votes
1answer
1k views

How to get proper parameters of SPH simulation?

I'm implementing basic fluid flow simulator using SPH method basing on e.g. https://www10.informatik.uni-erlangen.de/Publications/Theses/2010/Staubach_BA10.pdf. EDIT (dead url): https://www10.cs.fau....
5
votes
1answer
79 views

Mass matrix and BDF time integration

I have a system of nonlinear equations on the general form: \begin{align} \mathbf{M}(\bar{y})\dot{\bar{y}} =\bar{f}(\bar{y},t) \end{align} Where $\mathbf{M}(\bar{y})$ is a matrix and $\bar{f}$ is a ...
5
votes
1answer
162 views

How can I apply Euler's Method to predict a point in time rotating around multiple axis'

I am xposting this from my original stackoverflow question where I was presented with a coding challenge that I have been able to narrow down extensively and I think it lies with Euler's Method. Here'...
5
votes
1answer
389 views

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

Most authors are very clear that it's very dangerous to just use $\mathrm{H}(curl)$ conforming edge elements, which are divergence free, to satisfy $\mathrm{div}(\mathbf{B})=0$ and implement this ...
5
votes
1answer
303 views

How is rigid bodies implemented in finite element codes

I am writing a finite element code for structural analysis, and I want to implement rigid bodies. How is this usually done? Say that I have a square mesh, with one half of the mesh being defined rigid ...
5
votes
2answers
712 views

A Question About the Rhie-Chow Interpolation Used for Solving the Incompressible Navier-Stokes Equations on Unstructured Grids

When using the SIMPLE method on a mesh with a collocated variable arrangement, the following interpolation is used for the advecting velocities: \begin{equation} u_f = \overline{u}_f - \overline{D}_f\...
4
votes
2answers
2k views

Calculating partial trace of array in NumPy

A simulation I'm doing requires me to calculate the partial trace of a large density matrix. I am trying to calculate it using tools from numpy, but my code seems to be having some problems. For ...
4
votes
1answer
1k views

What determines the usual chemistry textbook plots of atom orbitals?

In elementary chemistry textbooks you often have pictures like the following one: Are there any conventions how to get them? I am not sure, but I guess that it are contour plots with only one iso-...
4
votes
1answer
73 views

Symplectic Algorithms for Hamilton’s Equations as opposed to just Volume-Preserving

this might be a silly question, but if we’re trying to numerically solve Hamilton’s equations with some discrete scheme, sometimes when the scheme preserves phase space volume (Hamilton’s eqns are ...
4
votes
1answer
118 views

How to force potential boundary conditions in the Yee scheme for solving Maxwell's equations?

Assume that we have a 2D electromagnetic field (in the sense that: $E=(E_x,E_y,0)$, $B=(0,0,B_z)$, and all derivatives with respect to $z$ are $0$), and that we are considering a system made up of two ...
4
votes
3answers
108 views

Mixing some particles together - “Game physics for engineers”?

I'd like to simulate how several particles mix together. For example, how do they settle when you throw them in a bucket? How do they assemble in zero-gravity? I might also want that they are "sticky" ...
4
votes
1answer
308 views

Fast Multipole Method in 3D

I am writing a FMM (Fast Multipole Method) algorithm in 3D. I generated the mesh and, currently, I am developing the expansion and the three (M2M, M2L, L2L) translation operators using spherical ...
4
votes
2answers
541 views

Manufactured solution for pressure based 3d incompressible Navier-Stokes solver with wall boundaries

I already successfully verified my solver (SIMPLE-type FVM-method) with the following manufactured solution (3d Taylor-Green vortex) on the solution domain $[-1,1]^3$ with Dirichlet boundary ...
4
votes
1answer
372 views

Is solving Verlet constraints parallelizable?

I am a computer science student and I came across the Verlet Cloth simulation. An implementation is here. I was interested in how such computation would lend itself to parallelization. The problem ...
4
votes
0answers
52 views

Phase dislocations and numerical accuracy

I am solving the nonlinear Schrodinger equation (NLSE), $$A_t+iA_{xx}+i|A|^2A=0$$ where $A$ is a complex valued function, which can be written as $A=ae^{i\theta}$ for $a,\theta$ real. Now, for ...
4
votes
1answer
547 views

Help with Fourier beam propagation method

I am working on implementing the Fourier beam propagation method in C++. I am really more of a programmer than a physicist but I think I have a good understanding of what I am trying to do. Here is ...
4
votes
1answer
408 views

Transform from constrained to unconstrained optimization

In a constrained optimization problem, I found in a paper a way to define new variables such that the constraints disappear. They only give the new variable definitions, and I would like to understand ...
3
votes
2answers
1k views

Why is it not computationally possible to accurately predict the weather that would occur after 14 days?

As per wikipedia, scientists have not been successful to accurately predict the whether which is 2 weeks ahead. Here is the excerpt: The atmosphere is a chaotic system, as a result, small changes ...
3
votes
1answer
964 views

Computer Build for Scientific Computing

I am currently a .NET software developer(SQL Server, ASP.NET, C#, MVC & Web Forms). In my spare time I'm researching different areas of environmental science. E.g.(Hydrology, Ecology, Atmospheric ...
3
votes
3answers
1k views

Understanding Finite-Element Modal Analysis

I am teaching a basic course on computational physics and for the last part of the course I will introduce freshman physics undergraduates to finite-element modelling methods. I am preparing a COMSOL ...
3
votes
1answer
113 views

Solve implicit ODE numerically in orbit simulation

I'm trying to plot the orbit of a compact binary star system where general relativistic effects become important. I'm using post-Newtonian approximation and I want to solve the orbit numerically based ...
3
votes
3answers
110 views

Numerically finding constants of motion

Given a set of ODE's $ \dot{z} = f(z) $ (or discrete time $ z_{t+1} = f(z_t) $), is there a way to numerically find constants of motion? For $ f(z_t) \approx M z_t $, diagonalizing the matrix $ M $ ...
3
votes
1answer
105 views

Doubt about Python code for calculation of Energy Conditions in General Relativity

In General Relativity, one possible way to decide if a space-time [i.e. a Lorentzian Manifold $(\mathcal{M}, \textbf{g})$ where $\textbf{g}$ is an arbitrary metric tensor.] is a "resonable physical" $[...
3
votes
1answer
109 views

Normalizing a density matrix at each iteration

I need to numerically evolve a density matrix using this formula(Actually I have more terms but right nows I am starting with this and facing problems): $$\dot\rho(t) = -i[H(t), \rho(t)]$$ $H(t)$ is ...
3
votes
1answer
349 views

Efficient Implementation of Taylor Series for Sine

I am trying out a few forms of polynomial expression optimization, and I'd like to improve of what I've got, if anyone has anything they know is better. Implementation 1: $$x-\frac{x^3}{3!}+\frac{x^...
3
votes
1answer
270 views

Finite Difference Beam Propagation Method problem

I am trying to implement the finite difference beam propagation method to study the propagation of a TE light signal through a waveguide. However, my solutions are exponentially growing, and display ...
3
votes
2answers
1k views

GPU-enabled Lattice Boltzmann solvers?

Is anybody aware of any GPU-enabled Lattice Boltzmann solvers (preferably on C++/OpenCL and open-source) that would be recommended? I have found Advanced Simulation Library, but it seems to be very ...
3
votes
2answers
819 views

Darcy Flow - Solution by Finite Difference

I'd like to model the fluid flow through a porous medium using finite differences. Since I am new to this numerical technique, I have a simple question. I use the following set of equations to ...
3
votes
2answers
114 views

Computational cost comparison of DNS and SPH

I may be incorrect, but it seems like commercial graphics codes typically use smoothed particle hydrodynamics (SPH) to produce stunning simulations and not continuum based methods. Why is this? Is SPH ...
3
votes
1answer
86 views

Computation of the heat kernel from Brownian motion

This question is rather simple but I have some difficulties to find code. Let us suppose that I wrote a routine, in a given language, that computes the evolution of a particle doing Brownian motion in ...
3
votes
1answer
443 views

ground state from the Schroedinger equation with a central potential what happens to the origin

I have code that attempts to implement a solution to the Schrödinger equation where there is a central potential (more or less im thinking of hydrogen), in 1-D using the numerov method to construct ...