# 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.

327 questions
Filter by
Sorted by
Tagged with
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 ...
5k 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 ...
6k 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.......
312 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 ...
1k views

### Conserving Energy in Physics Simulation with imperfect Numerical Solver

I am creating a C++ Physics Simulation where I need to move an rigid body through an acting force field. Problem: simulation does not conserve energy. Quesiton: abstractly, how is conservation of ...
1k 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 ...
8k 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: ...
2k 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 ...
3k 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 ...
502 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 ...
323 views

### Finite-difference software for solving custom equations

Are there any good, easy to use, software for simulating the evolution of systems of generic differential equations? I know there are custom programs for various specific circumstances (such as ...
598 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 ...
275 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 ...
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 ...
368 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 ...
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 ... 0answers 131 views ### Is a complete bacteria simulation with an exascale supercomputer possible? Will it be possible to simulate a complete (at least simple) bacteria atom by atom on an exascale supercomputer? or is it possible already today with the largest systems? Here, I've read that ... 4answers 239 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 ... 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$100of ... 1answer 8k 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 ... 1answer 106 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 ... 1answer 188 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 ... 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.... 1answer 240 views ### Consumer hardware for scientific computing? I'm interested in problems around probability, statistics, and statistical mechanics, and often I find it useful to perform simulations to get some sense of the underlying phenomena. Example ... 3answers 4k 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 ... 1answer 103 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 ... 1answer 166 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'... 1answer 442 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 ... 1answer 688 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 ... 2answers 830 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\... 1answer 162 views ### Absence of Discontinuity in Specific Heat Plot Simulated by Ising Model I am working on 2D Ising model, when I plot "specific heat vs temperature", I can't see any discontinuity at critical temperature around Tc ~ 2.7K. I am enclosing results of all other thermodynamic ... 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-... 1answer 80 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 ... 1answer 130 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 ... 3answers 116 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" ... 1answer 375 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 ... 2answers 557 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 ... 1answer 401 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 ... 0answers 54 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 ... 1answer 680 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 ... 1answer 414 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 ... 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 ... 1answer 1k 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 ... 2answers 143 views ### Solving a Boundary Value Question$\frac{d^2y}{dx^2}=y\cos(x)+\frac{\sin(x)}{x^2+2}$using Python I'm looking to solve this boundary value question using the shooting method! $$\frac{d^2y}{dx^2}=y\cos(x)+\frac{\sin(x)}{x^2+2}$$ given the initial values: $$y'(x=-1)=-1\\y'(x=5)=0$$ I'm aware of ... 3answers 2k 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 ... 1answer 115 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 ... 3answers 118 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 $... 1answer 123 views ### Difference between MoM and FEM Method of Moments and Finite Element Methods are two of the most used methods in computational electromagnetics to solve electromagnetic equations. As it is known, in FEM sparse matrixes are used ... 1answer 119 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"$[...
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 ...