All Questions

1
vote
2answers
121 views

Condition number of a matrix

I saw some definition that if $$M=\max_{x\not=0} \tfrac{\|Ax\|}{\|x\|} \quad\text{and}\quad m=\min_{x\not=0} \tfrac{\|Ax\|}{\|x\|} \,,$$ the condition number of $A=M/m$. In my opinion, If we have a ...
0
votes
1answer
102 views

Can OpenFoam be used for interactive simulations (flying a plane)?

I'm a software engineer and I've just started to fly rc-planes. I'm currently building a self learning auto-pilot for my plane and I'm really interested in CFD. I installed OpenFOAM and ran through ...
2
votes
1answer
76 views

How to choose a python parallelization library?

I want to preprocess a relatively large dataset using python. I implemented some Dask parallelization and was stunned by the time reduction. I figure there are other libraries or frameworks I could ...
0
votes
1answer
88 views

calculating integral for an ODE system

I have an ODE system defining a mathematical model of a biological system, say $$ \frac{da}{dt}=f_1(a,b,\ldots,z,p)\\ \frac{db}{dt}=f_2(a,b,\ldots,z,p)\\ \cdots\\ \frac{dz}{dt}=f_n(a,b,\ldots,z,p) $$ ...
1
vote
1answer
103 views

Find the roots of a complicated polynomial

For the polynomial $$p(x) = (x-1)(x-2) \cdots (x-20) - 2^{-23}x^{19}\, ,$$ I tried to use fzero() in MATLAB, and I set the interval to be $[0.5,1.5]\cdots [19.5,...
4
votes
2answers
98 views

SLATEC Routine Computes Givens Rotation in Unexpected Way

Some Background I am working on a C++ translation of a SLATEC routine, R1UPDT, which performs a Givens rotation: $$r = \frac{1.0}{\sqrt{a^2 + b^2}}$$ Usually, ...
6
votes
1answer
72 views

Solving a Hadamard + Linear System

I need to solve a matrix equation which contains a Hadamard product and a standard matrix multiplication: $$A\odot X + BX = C$$ where $A, C, X \in \mathbb{R}^{m \times n}$, $B \in \mathbb{R}^{m \...
16
votes
3answers
1k views

C++ Best practices for dealing with many constants, variables in scientific codes

I am developing a code to simulate fluid flow with biological substances present in the flow. This involves the standard Navier-Stokes equations coupled to some additional biological models. There are ...
0
votes
1answer
36 views

ISING2D with Mathematica. Searching a correct way to compute the heat capacity (mean values over several iterations)

I'm trying compute the heat capacity $C_v$ out of my simulation for the 2D-Ising model which is given by $C_v = \frac{\langle E^2 \rangle - \langle E \rangle^2}{T^2N^2}$ ($E$: Energy, $T$: ...
0
votes
1answer
38 views

Visualizing a trajectory in VMD

So, I've written a short python program simulating diffusion in 2D; in essence each particle is behaving like a random walker. The output is a 3D tensor, which for 4 particles and 10 timesteps, looks ...
0
votes
1answer
53 views

Debugging Newton-method used in a CG-approach

I am currently proof-checking my program, which is intended to use Newton's method for solving nonlinear equations, using a continuous galerkin approach. Thus, as first step I checked it using a time-...
0
votes
1answer
117 views

Heat diffusion - Is this the correct approach to include Newmann boundary conditions?

Thank you for looking at this problem. Is this the correct approach to include neumann boundary conditions? With this solution temperature is not correct, and there´s no diffusion. The model seems ...
1
vote
1answer
38 views

How to choose the parameters for a collision free comet trajectory

I implemented a simple simulation of a comet flying through space being deflected by the gravity of randomly generated planets for art purposes. My problem with that simulation is, that there are many ...
2
votes
1answer
70 views

Numerical integration of Fokker-Planck equation allowing for negative drift?

The Fokker-Planck equation (a.k.a Kolmogorov forward equation or Smoluchowski equation) describes the evolution of a probability density function and numerical integration of the FPE should conserve ...
9
votes
3answers
160 views

What is the reason that LAPACK uses $\tau$ in QR decomposition (instead of normalizing the reflection vector)?

LAPACK's QR routine stores Q as Householder reflectors. It scales the reflection vector $v$ with $1/v_1$, so the first element of the result becomes $1$, so it doesn't have to be stored. And it stores ...
7
votes
1answer
183 views

Size of jump for piecewise discontinuous approximations

If one has a sufficiently smooth function $u$ that is approximated by a piecewise constant function $u_h=\Pi^0_h u$ on a mesh of cell size $h$ (where $\Pi^0_h$ is the $L_2$ projection onto the ...
1
vote
1answer
73 views

Node renumbering in a 2D mesh

I have a 2D domain which is discretized using Q4 elements. I have the nodal positions and the element connectivity matrix. I would now like to renumber the nodes in such a way that all the interior ...
1
vote
2answers
112 views

How I could calculate L2 norm of an unstructured grid?

I want to calculate L2 norm of a 3D unstructured grid to compare my simulation results in two different mesh sizes as coarse and fine. I read this answer and it seems in three-dimensional space, I ...
1
vote
1answer
86 views

How to generate a face list from vertices?

I have a little background in writing toy finite volume CFD codes. In 2D Cartesian scenarios, I typically take $x_{\min}$, $x_{\max}$, $y_{\min}$, $y_{\max}$, and the number of points in $x$ and $y$ ...
2
votes
1answer
107 views

Poorly conditioned, easily evaluated sum for unit testing

I am looking for examples of poorly conditioned sums which can rapidly be evaluated, for the purposes of unit testing. I'm currently using the series representation for $\ln(2)$: $$ \sum_{n=1}^{\...
7
votes
1answer
185 views

Lack of quadratic convergence in Newton's method

It is well-known that Newton's method can converge quadratically, if initial guess is close enough and if the arising linear systems are solved accurately. I am applying Newton's method to highly ill-...
1
vote
1answer
96 views

Relation between conjugate gradient method and finite elements method

What is difference beetwen this two method? Are these methods far from each other or are these methods complement each other? Could you take an example?
0
votes
0answers
39 views

Correct order of convergence

I have a sequence of points which was obtained from an iterative algorithm, and I computed the order of convergence $p$ of the method using the formula $$ p \approx \frac{\log({\rm err}(k+2))-\log({\...
3
votes
1answer
71 views

Minimize a function with sparse Hessian

The problem I am trying to solve involves minimising a function with respect to a large number (probably 10,000+) of parameters. I can cheaply compute both its Jacobian and its Hessian. The Hessian is ...
2
votes
0answers
48 views

Unusual boundary conditions on Matlab

I'm trying to solve the following PDE by Matlab, $$ u_t-\Delta u = 0, \quad \text{in}\quad \Omega\times (0,T) \tag{1} $$ $$ u_t-\Delta_\Gamma u + \partial_\nu u=0,\quad \text{on}\quad \Gamma\times(0,...
-1
votes
1answer
31 views

Tabulting potencial LAMMPS [closed]

I have a potential for a molecule which depends on (r, theta, phi), also at different part cell has different variable, is it possible to tabulate such potential in LAMMPS? Thanks for your help.
2
votes
1answer
185 views

Which C++ linear algebra library is probably the fastest on solving huge sparse [square matrix] linear system?

I am developing a 2D CFD solver for fluid-particle interaction. To solve Navier-Stokes equations on a grid of size $10000\times 10000$ cells (or >1 million cells), a large linear system $Ax=b$ with $A$...
0
votes
0answers
12 views

Finding Duplicate Pixel/Objects along Image seams

I have a seam of two images joined by merging algorithm that on occasion generates duplicated pixels/objects/artifacts on both sides of the seam. The images are large and currently the seams are ...
1
vote
1answer
55 views

Correct weighting in least squares fitting

I am trying to fit some data points $d_i$ to a non-linear model function $m_i$, which depends on a number of fit parameters $f_k$ (I want to determine these) and also on some known, constant values $...
4
votes
1answer
86 views

Numerically find the nearest positive semi definite matrix to a symmetric matrix

I have a symmetric matrix $M$ which I want to numerically project onto the positive semi definite cone. To do so, I decompose it into $M = QDQ^T$ and transform all negative eigenvalues to zero. (...
1
vote
0answers
42 views

GMRES algorithm and Krylov base

I have a question about the precision of the GMRES algorith and its variation a s a function of the size of the Krylov subspace. I want to solve a Poisson equation using a spectral method. My problem ...
3
votes
0answers
85 views

WENO5 scheme in a staggered grid

I'm trying to use the finite-difference WENO scheme to solve the 2D density conservation law with axial symmetry (coordinates $r,z$): $\frac{\partial \rho}{\partial t}+\nabla \cdot (\rho \vec{v}) = \...
1
vote
0answers
63 views

Speeding up the solution of a large set of nonlinear algebraic equations in `sympy`

I have a quite large algebraic equation system to solve, the system is so large, I can't post the example here, so I am posting it to pastebin. The sympy.solve is ...
5
votes
1answer
96 views

Nullspace calculation of large matrix with rational numbers without round-off errors (exact)

I need to calculate a basis of the nullspace of large (up to a thousand columns and rows) matrices. For my application, it is very important that no round-off errors occur during the computation, so I ...
2
votes
0answers
81 views

Can I take advantage of a nearly banded A in AX=b?

I am working on a 1D drift-driffusion problem in a finite-difference (FD) approach. I hade 3 equations per node ($3N$ in total): electron continuity $E_i$, Poisson $P_i$, hole continuity $H_i$. With ...
0
votes
1answer
32 views

Langevin Thermostat and overdamped Langevin Equations

I'm having some difficulties understanding the Langevin thermostat (MD). In my notes, there is written that the Langevin equation is $$ m\dot{v} = F - m\gamma v + f_R, \tag{1} \label{1}$$ where $...
3
votes
1answer
129 views

Is this the correct way for solving coupled 1d PDEs using finite difference methods?

I am trying to solve the following coupled PDEs: $$C_e\frac{\partial u(x,t)}{\partial t} = k_{ed}\frac{\partial^2u(x,t)}{\partial^2x} - G_{el}(u(x,t) - v(x,t)) + S(x,t)$$ $$C_l\frac{\partial v(x,t)...
1
vote
0answers
27 views

Hydrogen-like wavefunction as starting guess for atomic solver?

I've been looking into radial solvers for quantum wave equations (Schroedinger and Dirac). In both cases, the suggestion seems to be to go with the "shooting method", with integration schemes of ...
0
votes
1answer
39 views

Formulate and solve a simple conic programs in cvxpy language [closed]

Let $r,\epsilon > 0$ and $a, b \in \mathbb R^n$ with $\|a\|_2 \le r$. Define $C(a) := \{x \in \mathbb R^p | \|x+a\|_2 \le r,\;\|x\|_\infty \le \epsilon\}$, and assume it is non-empty. Question (A)...
0
votes
1answer
62 views

Approximation of ODE solution using Taylor series methods

This is my first post on here, so please excuse mistakes if any. I am trying to plot out the difference between two ODE solvers based on Taylor series: 1st order acccurate: $x(t_0 + h) = x(t_0) + ...
0
votes
0answers
28 views

Determining the pseudo-time period of a system of $n$-pendulums via Kane's method in Python

We can use Kane's method to integrate the equations of motion for a system of $n$ pendulums with arbitrary masses and lengths (see derivation). In particular, if $(x_i,y_i)$ denotes the Cartesian ...
0
votes
0answers
32 views

In-exact line search

In my class notes, the author says: "If $f:\mathbb{R}^n \to \mathbb{R}$ is bounded below and $p_k$ is a descent direction and the $\alpha-\beta$ also known as Armijo-Goldstein condition is met then ...
3
votes
3answers
122 views

$H^1$-convergence rate of finite element method for Poisson equation, depending on element order

I wanted to verify my FEM-program by applying the method of manufactured solutions, while solving the Poisson equation in two dimensions using the continuous Galerkin method $$-\nabla^2u=f$$ with $$u=...
2
votes
2answers
137 views

Generate high n quantum harmonic oscillator states numerically

How can I generate the higher $n$ quantum harmonic oscillator wavefunction (in position space) numerically? Here, higher means around $n=500$, or say $n=2000$, where $n$ is the $n$th oscillator ...
2
votes
2answers
175 views

C standard for computational science

Which C standard should be used for computational science code ? Should we keep compatibility with C89/90/ANSI or jump to C99 or C11 ? Context: Code will use third-party : BLAS, LAPACK, MKL, ...
1
vote
0answers
86 views

How to simulate water, falling under gravity, and impinging on a curved surface, which is kept/present in a domain, containing air?

TL;DR: How do I simulate a hole, at the bottom of a (full) water tank? I am attempting to simulate water, flowing out of a hole/slit, at the bottom of a tank (Water Domain) (under the influence of ...
1
vote
0answers
35 views

Computing a Flux Integral in Paraview

I am currently looking into post-processing of simulation data using Paraview. I would like to compute certain integrals of field quantities. As an example, consider the following surface integral of ...
1
vote
1answer
89 views

Computing the Inverse of a matrix, using the Cholesky decomposition

I have to compute $CA^{-1}B$ and $CA^{-1}x$, where $A,B,C$ are conformable matrices and $x$ is a vector. I've read that the a very computationally stable way to compute these inverses is by computing ...
4
votes
0answers
82 views

Best way to numerically compute elliptic integrals of the third kind with complex arguments?

I need to compute elliptic integrals of the third kind with complex arguments, preferably in C++. Is there code out there to do this? I have discovered the Arb library, but that does much more than I ...
4
votes
2answers
91 views

Analytical convergent sequence and numerical divergent sequence

Is it possible to construct a sequence that converges in theory but when computed numerically with a computer program is diverging. I feel that today our computer programs doesn't allow such ...

15 30 50 per page