instruction
stringlengths
43
28.1k
I am playing around with Elemental's distributed singular value decomposition and am running into two particular issues. Building the test at tests/lapack_like/SVD.cpp, and running with mpirun -np 4 ./SVD --height 3 --width 3 I get SVD residual was unacceptably large for the distributed Complex<float> test (but seque...
In physical problems, it's quite common that we need to solve for specific eigenvalues in the complex plane, e.g. with a positive real part and negative imaginary part. In this case, we are looking for eigenvalues and associated eigenvectors in the second quadrant. I am curious if the FEAST algorithm could deliver fast...
From my knowledge if you fit geometrical objects into point clouds you want in general minimize the squared distances of the point cloud to your fitted objects. I do so with the downhill simplex method by minimizing the average squared distance. I fit cylinders. In rare input scenarios I end up having not good fitted c...
I heard about Ramdisks some years ago and even set up one for testing on mymachine. I didn't test it thoroughly so I couldn't really judge the performance improvements (in comparison to plain a SSD). Ramdisks are in short parts of your working memory, which are allocated to a logical(software) disk. Therefore you can a...
Recently,I dive into a set of somehow ancient Fortran codes and try to fully understand them. A large fraction of these codes are multiple layers of loops over many state variable dimensions, which are aiming to find policy function(fixed point). That's OK, but what's really annoyed me is the messy expression of the gr...
I am a beginner in computational science and programming. I am doing research in non linear solid mechanics analysis and using C++ for coding. I have been exploring various finite element open source programs and saw some nice works like Deal.ii, FEniCS, OOFEM, libmesh. But as a beginner in C++ programming and finite e...
I have a problem with the following equation: $$ V_r\frac{\partial C_A}{\partial r} + \frac{V_\theta}{r}\frac{\partial C_A}{\partial \theta} = \frac{2}{Pe_A} \left[ \frac{\partial ^2 C_A}{\partial r ^2} + \frac{2}{r} \frac{\partial C_A}{\partial r} - k C_A\right] $$ I'm trying to solve this with finite difference tech...
I am looking for a PDF describing Chinese character component-based layout engine algorithms. These should allow for recursive encodings of radical and non-radical components, and the encodings should account for the structural layout of characters based on these layouts. Thank you.
my aim is to interpolate a function like this: I have |<--- h -->|<-------- k ----------->| o----------o------------------------o x(i-1) x(i) x(i+1) with respective values $f(x_i-h), f(x_i), f(x_i+k)$, now I want to approximate $f(x+k/2)$ using centered formula. I know for ex...
I am not very familiar with differential equations, nor physics in general. I am trying to program an object falling with air resistance with the use of a numerical algorithm called Runge-Kutta. The object is going to fall from the same position every-time $x=0$, with the same start speed $v=0$ every time. I think I t...
The Dirichlet boundary condition is $n \times \vec{E} = n \times \vec{g}$. I don't know how to calculate the boundary value. Any kind of help would be appreciated.
For 1D finite difference, the resulting linear system is tri-diagonal and can be solved in O(n) using the Thomas algorithm. I am trying to solve a finite difference system in 3D. Numerical Methods by Quarteroni et al goes over some theory behind extending the Thomas algorithm to block linear systems. This method seems...
Motivated by this top answer to the question: Why is convexity more important than quasi-convexity in optimization?, I am now hoping to understand why convex problems are easy to optimize (or at least easier than quasiconvex problems). What are some of the most efficient algorithms for convex optimization, and why can'...
I'm trying to do biologically based locomotion animation. I have a Hill-Type Muscle Model (see reference 1) that I've implemented in code. I can find the initial lengths of the tendons, then do a step and find the new velocities and forces. My question is, how do I use this information to simulate the muscle? Specifica...
I have a 2-dimensional system which I would like to solve numerically (I'm using finite difference method right now), and its an eigenvalue problem. I have a term that looks like $H\psi(x,y) = [-\frac{1}{2}(\frac{\partial^2}{\partial x^2} +\frac{\partial^2}{\partial y^2})+ i(y\frac{\partial}{\partial x} - x\frac{\parti...
I have read this and other threads on this site on BFGS, but I still don't have a clear understanding of what it's meant by low-rank updates. For example, I read the following in this book: The approach adopted by quasi-Newton methods (of which the BFGS algorithm is the most prominent) is to approximate the inverse ...
The last couple of hours I have been looking for an unconditionally stable method to solve the convection-diffusion equation within a 3D inhomogeneous material. Here's the well known diffusion-convection equation: $$\rho(\vec{r})C_p(\vec{r})\frac{\partial T(\vec{r},t)}{\partial t}=\nabla [\kappa(\vec{r})\nabla T(\vec{...
I'm trying to learn SPH by implementing different methods. I am currently following Divergence Free Smoothed Particle Hydrodynamics By Jan Bender [1]. I believe I understand the method and the math behind it. However I am not a able to correct the density error by finding the pressure forces because they are very small...
I'm somewhat struggling with how they are getting this scheme. This is a problem from Morton & Mayers book on numerical pde solutions. I think they are using a forward difference approximation for the 2nd order x-derivative but I just can't seem to figure out how. Sad day for me, but I would appreciate any insight. I t...
I'm trying to solve the PDE for $c(r,t)$ $$c_t=(1/r)(rJ)_r$$ using Crank-Nicolson, and I'm having difficulty with the boundary conditions. $J$ is the flux, the initial condition is $c(0,r)=c_{init}$, and the flux is 0 at both boundaries $r=r_0$ and $r=r_1$. The flux is $J=rDc_r-s\omega^2r^2c$; $D$ and $s$ may be functi...
I am wondering how to draw a sample complexity plot similar to the following figure which shows the estimated number of samples to incur no more than 10 percent generalisation error on average for the least squares algorithm for classification. The problem assumes that we have $m$ patterns $\mathbf{x}_1,...,\mathbf{x}...
Is there a faster way to compute the nuclear norm (trace norm, sum of singular values) of a matrix A than computing SVD(A) directly (or diagonalizing A^*A)? I am particularly interested in the case where A is square. Assuming that A is real would be OK too. I am thinking in the limit of large matrices.
I am trying to solve a differential equation system $$x´=Ax\quad \text{with } x(0) = f(x)$$ in Python, where $A$ indeed is a complex sparse matrix. For now i have been solving the system using the scipy.integrate.complex_ode class in the following way. def to_solver_function(time,vector): sendoff = np.dot(A, np.tr...
Question Below is a plot of a graph $y$ and its derivative $dy/dx$ calculated using python's numpy.gradientwhich approximates the derivative with finite differences using a central scheme. Clearly there is a problem in that unphysical kinks have been introduced in the result. Since differentiation will act to amplify ...
Most mesh generation software seems to be aimed at building nicely shaped elements for FEM. I'm curious about a different situation: I need to numerically integrate over an irregular region. I don't need to solve for any unknowns in this region -- just integrate a known function. And I need to integrate over many such...
For some time I wrote every bit of my code by myself without using external sources. However after my problems became more complicated I decided to use external libraries. For example to save and inspect the solutions of my computations, I chose to use vtk. I understand, that I cannot write everything on my own, but I ...
I have the following question. I have a code function that computes right-biased and left-biased approximations of the derivative of a function using WENO5 for Hamilton--Jacobi equations as described in @Article{Jiang2000, Title = {Weighted {ENO} Schemes for {Hamilton--Jacobi} Equations}, Author ...
Introduction to Problem I'm using a Truncated Signed Distance Function to perform 3D reconstruction from depth images. Essentially I have a large voxel grid where each voxel contains the signed distance to an implicit surface. The surface can be extracted form the Voxel Grid using a marching cubes algorithm to generate...
I have two computers, both with 4-cores and I am running some heavy computational stuff in one of them using Intel Parallel Studio Cluster edition. I am coding in fortran and making extensive use of OpenMP to parallelize the loops. I read that it should be possible to run this code using the two computers at the same ...
I am trying to evaluate the Exponential Integral $Ei(x)=-\int^{\infty}_{-x}\frac{e^{-t}}{t}dt$ for $x>0$ (interpreted as the Cauchy principal value) by using rational Chebyshev approximations, which can be found in a paper by Cody & Thacher "Chebyshev Approximations for the Exponential Integral $Ei(x)$". The paper is a...
Now I have been believing that FEM/CFD is supposed to be faster on a GPU unit - here I am using CUDA as solid example. However, I have not been able to find a convincing paper where the benchmark actually appear to me that 'Yes, this is true!'. Can I please be pointed to one? Or if not, is there any reasons why GPU u...
It is my understanding that the multigrid solution techniques are generally the preferable method to solve large Poisson problems. Now assume I have written a multigrid solver that is tailored to my special needs that actually works quite well, i.e. the residual norm decreases by a factor ~10 with every successive V-cy...
I am applying a 4th order Runge-Kutta code, using the method of lines, to solve the following: \begin{equation} \frac {\partial y_1}{\partial t} = y_2 y_3 - C_1 y_1 \end{equation} \begin{equation} \frac {\partial y_2}{\partial t} = y_3y_1 - C_2 y_2 \end{equation} \begin{equation} \frac {\partial y_3}{\partial z} = y_4...
There is a huge literature on efficient preconditioners for saddle-point problems. In computational physics, the case where the Lagrange multipliers enjoy a weak formulation (say, the Stokes equations) is almost always considered. In such cases, very fast solvers can be designed. Unfortunately, in structural mechanics,...
I was trying to understand how to use the inverse interation method to compute the page rank as an exercise. In this chapter (page 4) about page rank (by Cleve Moler), the author suggests to use the following statements to compute the page rank using the inverse iteration: c = sum(G, 1); k = find(c ~= 0); D = sparse(k,...
I have a discrete contour represented by a set of points. The contour looks like a polygon but if you zoom you see that the edges are rugged (that's because it was obtained while working on a finite differences grid) I would like to fit a polygon to this contour (which is closest in the least-squares sense). Are there ...
I have a working SPH simulation in 2D. When the particles are in motion everything works fine. But once the simulation comes to a rest particles at the bottom begin to oscillate violently and eventually penetrate the boundary particles. I have tried dampening the simulation with two types of viscosity, XSPH and Artific...
I am interested in writing a simple, cell-centered, 2D FVM code for the unsteady, compressible Navier-Stokes equations (including shocks). Most of my experience is with finite difference and finite element methods. I did develop a finite volume code for Sod's problem as a learning exercise a while back. I've been se...
The equation is: $\partial f/\partial t + \nabla \cdot (v f) = 0$ $, \;\; f \in [0,1] $ and $v$ is a velocity known at every grid cell. A more precise constraint is that $f$ is either 0 or 1 but I can also live with it being in the domain [0,1]. The geometry is 2D cylindrical R-Z coordinates. For the Initial condit...
I am running a PCA analysis on a data set using Python's (v2.7.10) NumPy. I validated that my program works by running the PCA analysis on a smaller dataset and then confirming that I get similar results using sklearn.decomposition. When I run my full dataset (with 60000 variables and 93 samples), I experience some st...
I am solving the simple 2nd-order wave equation: $$ \frac {\partial ^2 E}{\partial t^2} = c^2 \frac {\partial ^2 E}{\partial z^2} $$ Over a domain of (in SI units): $ z = [0,L=5]$m, $t = [0,t_{max} = 5]$s, $ c = 1$ m/s and boundary/initial conditions: $$ E(z=0) = E(z=L) = 0 $$ $$ E(t=0) = -E(t=t_{max}) = sin(\frac{\pi ...
I am currently trying to get through Pattern Classification by Duda et al (for a course). However, the book seems too dense for me. Pattern recognition seems like a topic that could be better learned through guided discovery. That made me think... There is a a thread over at mathematics SE about books that teach math b...
I am using an open source FEM platform, which requires you to convert your equation system to non-dimensional form. So, there are no units specified for the parameters in the problem. If you use compatible input units, you should expect the output in matching unit - just like one would do in a normal python or C++ code...
I am currently working on my bachelor’s diploma. The research concerns mixed finite element method for the 2D Stokes system $$ - \Delta \boldsymbol u + \nabla p = \boldsymbol f, \quad \boldsymbol x \in \Omega \subset \mathbb R^2, \\ \nabla \cdot \boldsymbol u = 0, \quad \boldsymbol x \in \Omega, $$ with homogeneous Dir...
I'm looking to numerically evaluate $\log f_p(z)$ and its derivative $f^\prime_p(z)/f_p(z)$ accurately and efficiently in floating-point, where $$ f_p(z)=\int_0^\infty r^{p-1} \exp\left(-\tfrac{1}{2} (r-z)^2\right)\,dr \ . $$ Let $\phi(x)$ and $\Phi(x)$ be the PDF and CDF of the standard normal distribution $x \sim \m...
I am solving Biot equation with sparse matrix in MATLAB. I have no problem with global sparse matrices assembly, but when I assign Dirichlet boundary condition, it is so slow. From this topic, How to efficiently implement Dirichlet boundary conditions in global sparse finite element stiffnes matrices, @James also menti...
Consider the equations $$\int_0^L \mathbf W(\mathbf u, s) \, \mathrm ds = \mathbf 0$$ where $0 \leq s \leq L$ and $\mathbf u$ is a vector of constants. Numerically, what is the best way to determine $\mathbf u$ that satisfy the equations?
I have two large-ish matrices (~100K cols x ~100K rows). They are sparse and symmetrical (about 0.1% of them values are non-zero). I want to do element-wise multiplication between them. Also, I plan to perform this operation about 1,000,000 times, so speed is is definitely going to be an issue. Does anyone know of a go...
I'm kind new in the Computed Tomography field and I'm trying to understand and implement ART technique. Said it, I started to read the book The Mathematics of Medical Imaging - A Beginners Guide by Timothy G. Feeman. In the chapter 9, author describes the ART method. Well, If I understood fine (correct me If I'm wrong,...
I have an objective function that I can write either in quadratic programming (QP) such as $$\sum_{i=1}^N \sum_{j=1}^N C_{ij}^2$$ or as an LP problem $$\sum_{i=1}^N \sum_{j=1}^N |C_{ij}|$$ which can be done by splitting $C_{ij}$ into two parts $C_{ij} = C_{ij}^+ + C_{ij}^-$ and imposing $C_{ij}^{+}>0$ and $C_{ij}^{-}>...
I want to simulate a molecular system at a certain temperature. It would be best if it could be implemented by NVT molecular dynamics. However, if one were to use a NVE simulation (like velocity Verlet), how could I fix the temperature, or let the temperature only fluctuate a little bit around the desired value?
I'm comparing some of the different ODE integrators in scipy.integrate.ode on solving the logistic function: $$x(t) = \frac{1}{1+e^{-rt}}$$ $$\dot{x} = rx(1-x)$$ I've heard that LSODA should be very good, so I was a bit surprised to find that it fails completely for $r>4$. The dopri5 integrator, on the other hand, seem...
I have two identical computers, both with 4 dual cores and MATLAB installed on them. They are connected to the same network. Is there anyway I can run a parforloop using the computation power of both machines without relying on MATLAB distributed computing server? I do not have a license for this, and seems to expensiv...
I am preparing to do a MD-simulation of a system which consists of two phases. The gaseous phase consists of $H_{2}$, $Ar$, $He$, $N_{2}$, $CH_{4}$ and $CO_{2}$. In this system, $p=0.355 ~bar$ and $T\approx 350 K$. In direct contact with this phase is an aqueous phase, consisting of the same components and water. I've ...
I need to build a new desktop PC, where ab-initio DFT calculation going to be performed. I am searching for a CPU in value range 600 - 1000€. I was thinking about six-core Intel Core i7-6850K or 8-core Intel Core i7-6900K. However Intel Core ix processors are desktop processors so they are optimized for multimedia appl...
I am looking for an open source solver to solve the a quadratic programming problem with an additional piecewise linear objective, as show below. The problem is fairly small ($\mathbf{x}$ is a vector of dimension 120). \begin{equation*} \max_{x}: \mathbf{x}^{T} \mathbf{q_0} - \mathbf{x^{T}} P_0 \mathbf{x} - f(\mathbf...
I wonder how one manages to use BLAS level 3 operations in the multifrontal sparse decomposition algorithm. As far as I understand, the algorithm proceeds as follows: For each row/column pair, assemble the dense matrix corresponding to its nonzero entries. Write this matrix as $$ M = \begin{pmatrix} \alpha & a...
After trying to use RK4 to solve the below system of equations, it appears the output had large and fast oscillations even with an adaptive time step I incorporated using the Cash-Karp method. I am now looking to existing solvers with more sophisticated tools (e.g. BDF methods) to solve PDEs, and came across odespy whi...
I am trying to reproduce this figure of nodal lines of a wavefunction from this work of Berry $$\psi = \sin 2r\,x \sin y + (1 + \epsilon) \sin x \sin 2r\,y$$ Here the image. The first is $\epsilon = 0$ and the second is $\epsilon > 0$: I produced a script to evaluate the value of sine at many points using numpy. Her...
I came across this form of damping implemented in an elastodynamics problem. The stress tensor without the damping would look like: $ \sigma = 2 \mu \epsilon + (\lambda \, \text{tr} (\epsilon)) I $ where, $\mu$ and $\lambda$ are Lame' parameters dependent on the Young's Modulus and the Poisson's ratio. Trace is repres...
I'm sorry for this silly question. Several times I faced with optimization problems which can be expressed as $$\begin{array}{ll} \text{minimize} & \mathrm x^T \mathrm A \mathrm x\\ \text{subject to} & \|\mathrm x\| = 1\end{array}$$ where $\mathrm A$ is square matrix and $\mathrm x$ is vector. (This kind of problem ar...
If I take the step too large I will get error, while if I take the step too small I also get an error. In my case, instead of seeing the function decreasing, i have it increasing if I take the step too small.
I am implementing higher order derivatives for FEM. Example, to solve a Poisson problem, biharmonic or triharmonic PDE one needs first, second or third order derivatives respectively. As usually done in FEM, there is a mapping from a reference element to a physical element e.g. $F : \hat{K} \rightarrow K$ with the ass...
In NVT molecular dynamics, Nosé Hoover thermostat is a method defining an extended system. I can understand perfectly how the Nosé Hoover differential equations are derived (Frenkel&Smit's book). However, when it comes to practice, I have no idea how to solve it numerically. I tried a method similar to velocity Verlet ...
I've been using HDF5 for years, but as the size of the dataset grows I'm starting to experience the same problems listed here http://cyrille.rossant.net/moving-away-hdf5/ Can you point me to a format like HDF5 with - Good support for parallel writes - Support for chunked access of huge matrices My typical use case is a...
I've the following Matlab code: r = symrcm(A(2:end, 2:end)); prcm = [1 r + 1]; spy(A(prcm, prcm)); where A should be sparse connectivity matrix. I understood what it does: Finds a permutation vector r of the submatrix of A A(2:end, 2:end) (produced by the reverse Cuthill-McKee algorithm) Creates a vector prcm which...
I am solving a quadratic program with regularization parameter $\alpha\geq0$ to get the solution to a problem of the form $$ p(\alpha):= \arg\min_{p\in\mathbb{R}^n}\ [\alpha(v^\top p)+f(p)], $$ where $f(\cdot)$ is a strictly convex, continuous, and piecewise quadratic function of $p\in\mathbb{R}^n$. I'm hoping to say s...
Assume we use FEM with piecewise linear finite elements to discretize the BVP over $\omega = (0,1)$: $-u''+ bu' + u = 2x$, $u(0) = u(1) = 0$ for parameter $b\in R$. Given a mesh $T = \left\{x_i\right\}_{i=0}^{N}$ where $x_i = 1 - (1-\frac{i}{N})^{\beta}$ for some $\beta > 1$. Using principle of error equilibration, fin...
The Schrodinger equation for time-dependent Hamiltonian is $$i\hbar\frac{d}{dt}\psi(t) = H(t)\psi(t) \, .$$ Assuming I knew $\psi(t)$, I want to know $\psi(t+\Delta t)$. Should I take exponential or use ode solver? I know that the mathematical solution after one timestep should be (or not?) $$\psi(t+\Delta t) = e^{-\f...
If this isn't the right SE site, please suggest the right one? Can software remove all distortion from a 180-degree lens? In other words, if the goal is to optimize for distortion-free images, would a stereo configuration with two 100-degree lenses and two sensors (overlapped to provide 180-deg coverage) be better tha...
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 leapfrog, yet leapfrog conserves energy and RK4 doesn’t. Why is this?
The main motivation behind my next question is that I think I derived a higher order numerical scheme for linear advection equation that is unconditionally stable using Von Neumann stability analysis. In the stability analysis of the numerical scheme I have to find the maximal value of so called amplification factor $|...
Is there any method to deal with this problem? I am using Mathematica to solve the differential equations, but the calculating time is so long because of the large domain $x\in[0,10^{6})$. In fact I don't need the valves of y at x=0,0.01,0.02,0.03....I just need the values at x=0,1000,2000... or even less dilute. But t...
In an N-body simulation where forces between particles are attractive and particles do not lose energy on colliding with walls or each other, should energy be conserved? How could it be, with total kinetic energy increasing to unlimited values and total potential energy capped by the number of particles and their close...
Basically, FEM seems to be a problem that is pretty much "solved". There are numerous powerful frameworks existing, like Trilinos, PETSc, FEniCS, Libmesh or MOOSE. One thing they have in common: They are extremely "heavy-weight". First, the installation normally is super painful. Second, their interface/API is thick an...
I want to vary the input parameter of a physical dynamic mechanics problem, as a Gaussian Random variable and view the resulting Probability Density Function (PDF). I used the Finite Element Method to create deterministic codes in C++ and Python language. However, before I go there, I want to begin by applying this tec...
So I'm working with a rather complicated dynamical system. Instead of writing it all out. It's probably easier if you just clone my git repository. git clone https://gitlab.com/mdornfe1/vortex_acoustic The dynamics of the system is encoded in the function flow inside vortex_acoustic.py. If I integrate the system from ...
I am trying to estimate a few unknown parameters of my continuous non-linear PDAE model (simulated through finite-volume method spatial discretisation, and time-stepping through method-of-lines). I am planning to do this by minimising the least-squares error of the model output to experimental data. I read about the v...
I am trying to solve an elliptic PDE in 2-D: $$-\nabla^{2} u = 20tanh(10x-5)(10-10tanh(10x-5)^2) = f$$ I know that the solution is $u = tanh(10x-5)$ but I am unable to get $O(h^2)$ solution with a cell-centered, finite-difference on a uniform mesh with Dirichlet boundary conditions. Discretization : central differenc...
I am trying to numerically solve a PDE, and just had a question as to the validity of a certain approach. For example, given the PDE: $$ \frac {\partial ^2 E}{\partial t^2} = - k\frac {\partial E}{\partial t} + c^2 \frac {\partial ^2 E}{\partial z^2} - c\frac {\partial E}{\partial z}$$ If I was to apply an explicit R...
I have a convex optimization problem as follows: \begin{align*} maximize_{x\in R^n} &\sum_{i=1}^n a_i log(x_i)\\ st\quad & \sum_{i=1}^n p_{ij} (x_i-1) = 0 \quad \forall j\\ & x_i \geq 0 \end{align*} where, $a_i \geq 0$ and $P$ is an $n\times m$ probability matrix with rows sum up to 1. Is...
I am reading the paper, http://math.mit.edu/~gs/cse/codes/mit18086_navierstokes.pdf It says applying the divergence to both sides of this equation $$\frac{1}{\Delta t} U^{n+1} - \frac{1}{\Delta t} U^{n} = - \nabla P^{n+1} $$ yields the linear system, $$-\Delta P^{n+1} = - \frac{1}{\Delta t} U^{n} $$ Why does the $\fr...
I have the following problem, there is an objective function f() depending on 7 variables x=(x1,x2,...x7), so f(x)=f((x1,x2,...x7)) and I want to find the combination of variables that minimize the objective function (x* for which f(x*) is minimum). The formula of the objective function is unknown. The problem is that ...
I am reading the paper, http://math.mit.edu/~gs/cse/codes/mit18086_navierstokes.pdf I could not really understand the description. Could someone explain a little bit more? It says, "For the lid driven cavity problem this means that homogeneous Neumann boundary conditions are prescribe everywhere. This implies in partic...
I am looking for a good numerical method to solve a linear system (of small/moderate size) with a matrix of the form $$ \begin{bmatrix} a_1 & b_1\\ & a_2 & \ddots \\ & & \ddots & b_{n-1}\\ b_n & & & a_n \end{bmatrix}. $$ What would you suggest? Entries not displayed are zero. The $a_i$ and $b_i$ entries can be arbitrar...
Let $\bar{x}$ denote the analytical solution of a PDE. Let $x^{(k)}$ be the solution at the $k^{th}$ iteration. The initial guess for the solution is $x^{(0)} = 0$. Let $r_{0} = ||\bar{x}-x^{(0)}||_{2}$ i.e. the $l_{2}$ norm of the error. Let $r_{k} = ||\bar{x}-x^{(k)}||_{2}$ be the $l_{2}$ norm at the $k^{th}$ iterati...
I have a quantum mechanics simulation where I need to multiply three matrices that look like this: $$\rho(t_1)=U^\dagger \rho(t_0) \, U$$ where $U^\dagger$ is the hermitian conjugate of $U$. This evolves the density matrix $\rho$ from one time point to another time point. $U$ is called the evolution operator. My questi...
Hi I want to approximate $u(x,t)$ solution of: $\begin{cases}u_t+H(u_x)=0 \\u(x,0)=u_0(x)= e^{−(x−3)^2} \end{cases}$, where $H(u_x)=\frac{u_x^2}{2}$ and my spatial domain is $\Omega=[0;10]$. Now i want to apply Hopf-Lax formula (Evans' chapter 3 theorem 4), who says $u(x_j,t_n+\Delta t)=\min_{a\in \mathbb{R}} \left\{ ...
Hi I am trying to take a derivative of an array but am having trouble. The array is two dimensional, $x$ and $y$ directions. I would like to take a derivative along $x$ and along $y$ using central difference discretization. The array has random values of numbers, no values are NaN. I will provide a basic portion of...
I am reading the paper, http://math.mit.edu/~gs/cse/codes/mit18086_navierstokes.pdf In the paper, the nonlinear term is treated as mix of central central difference and upwind difference using a transition parameter $\gamma \in [0,1]$, and it's defined as $$\frac{U^*-U}{\Delta t} = ((\bar{U}^h)^2 - \gamma \lvert \bar...
I am new to MPI and am trying to figure out the subtleties in it, and for that reason I am just playing around with an easy example. The question I have is that when I run the code below with 2 processors, even though the printf statement is BEFORE the MPI_Init both processors print it. Is there anyway to not have this...
A dull matrix multiplication algorithm where we use the formula $$C_{ij}=\sum_{k}A_{ik}B_{kj}$$ By literally following this in 3 loops we'll get a very slow program, because we don't utilize processor's vectorization power. An example of this slow implementation is: T comp; for (int i = 0; i < lhs.rows(); i++) { fo...
Consider the 1D Poisson equation $$\nabla^2 u = f.$$ Using finite difference method on cell corner data and a uniform grid with ghost points, I think we can write the system of equations with Neumann BCs as: $$Au = f-Au_{BC},$$ where $$ \begin{aligned} A &= \frac{1}{\Delta x^2} \left[\begin{array}{ccccccccc} -2 & 2 ...
Here is the flow past a square cylinder configuration. The problem is a viscous and incompressible with parabolic velocity profile using freestream velocity $U$ across a single cylinder. I use the single relaxation time lattice Boltzmann method. For the two-dimensional nine-velocity lattice(D2Q9), the directions of the...
I wanted to implement a basic example from the book "The Art of molecular dynamics simulation" in LAMMPS. It describes the 2d-movement of molecules in a Lennard-Jones-potential, defined as $$u(r_{ij})=\left\{\begin{matrix}4\varepsilon\left[\left(\frac{\sigma}{r_{ij}}\right)^{12}-\left(\frac{\sigma}{r_{ij}}\right)^{6}\...
I want some scalar spline function defined on regular 2D grid $F(x,y)$ with continuous first derivative which is easy to intersect with arbitrary ray/line ${\vec l}(t) = (c_x t,c_y t,c_z t)$. Finding the intersection means finding roots of equation $f_{c_x,c_y}(t)-c_zt=0$ where $f_{c_x,c_y}(t)=F(c_x t, c_y t )$ are ...
Suppose we have equation of the form: $$H \Psi = E \Psi $$ where $H$ is Dirac Hamiltonian (also my question can be answered by people who are not familiar with Dirac Hamiltonian but familiar with numerical solution of different eigenvalue problems): $$ H = \vec{\alpha} \vec{\nabla} + V(r) = H_0 + V(r)$$ and $\vec{\alph...
How to normalize the CPU time for comparing algorithm execution time on systems with different hardware configurations?
I have to solve a least squares problem: $$ x=\arg \min\|Ax-b\| $$ where $A$ is a $m\times n$ matrix, $m>n$, and $b\in\mathbb{R}^m$. I always thought that doing this via QR factorization is better than solving the normal equations $$ A^*Ax=A^*b $$ directly. However, I am now in the situation where the columns of $A$...
Edit: (copying from my comment) Let's consider the inverse problem when I need to transfer velocities from particles to the grid (inverse bilinear interpolation). How'd I transfer a particle's x-velocity to the velocities located at cell's face in the Q region? Would the particle's velocity be distributed among the 2 f...