instruction
stringlengths
43
28.1k
By writing the direct integration of the 2D Euler Equations in a wide and short box where the fluid enters and exits through the horizontal faces using the Runge Kutta O(4) method I have found that the CFL coefficient, here approximately computed as follows, oscillates with an increasing amplitude over time. If integra...
Let's say I have a 2x2 matrix (with symbols) called 'A'. Now, if do B = sympy.tensorproduct(A,A) print(sympy.shape(B)) I get, (2,2,2,2) which is a 4 rank tensor. However, what I want back is a 2 rank 4x4 matrix. How can I do that? I tried reading documentations for sympy and found out about reshape. But it didn't ...
Cross-posted from Stack Overflow. (https://stackoverflow.com/questions/70686368/can-i-use-periodic-boundary-conditions-for-u-but-not-for-p) I am trying to numerically compute the drag force around a cylinder due to pressure-driven flow. Here is a crude diagram: I am using OpenFOAM v2012 (the openfoam.com version, not ...
I'm currently trying to implement a python script for solving a constrained nonlinear optimization problem with ~800 variables and 2 constraints, one linear and one nonlinear. There already exists a Matlab implementation of this script and I'm trying to use cyipopt to implement an equivalent Python implementation that ...
I have a system of 2 non-linear, coupled PDEs that I would like to transform to a stiff ODE system to solve them using the method of lines. The 2 equations: $$\begin{align} \frac{\partial \phi}{\partial t} &= - \phi^m \frac{P}{R - H(P)(R-1)}\\ \phi^m \frac{P}{R - H(P)(R-1)} &= \nabla \cdot [\phi^n(\nabla P + u_z)] \end...
Background I want to solve the following biharmonic equation: $$\frac{ \partial^4 s }{ {\partial \xi}^4 }+\frac{ \partial^4 s }{ {\partial \xi}^2{\partial t}^2 }+\frac{ \partial^4 s }{ {\partial t}^4 }=0\label{1}\tag{1}$$ on the unit square with the four Edges E1, E2, E3, and E4 (Fig. 1 left) and its prescribed boundar...
Even if the formulation is the same the TVD slope limiter can be applied: to state reconstruction at the interface, in 1D FV formulation, we reconstruct the $Q^*_{j+1/2}$ and the $Q^*_{j-1/2}$ in the formulation: $$ Q_J^{n+1}=Q_J^n+\frac{\Delta t}{\Delta x}\left[F\left( Q^*_{j+1/2}\right)- F\left( Q^*_{j-1/2}\right)\r...
I need some good references on how to implement programmatically the hp-refinement of meshes in the Finite Element Method in two/three-dimension. I've searched the web a lot and read many articles and books without success. Most of the references in this regard have only concisely discussed the details of the hp-refine...
I have a linear system of the type $A x = y$ where A is a dense, square, symmetric, positive definite matrix, $x$ a vector of unknown parameters, and $y$ is a vector of observed quantity. I know that using a Cholesky decomposition based algorithm should be the fastest way to find the values of $x$ that fulfil the equat...
I am currently trying to compute the value of the first Fibonacci number recursively. the idea is as follow: Compute $f_{n}$ and $f_{n-1}$ for $n = 2,...,100$, Compute $f_k$ for $k = n−2, n−3, \dots, 0$, Call $\hat{f}_0(n)$ the value of $f_0$ computed as a function of $n$. Here is the Matlab code I used: N = 101; n =...
A basic question on low Reynolds number hydrodynamics. When a slender beam is moved through a fluid, the dynamics may be calculated using slender body theory (e.g. Slender-body theory for slow viscous flow J. B. Keller and S. I. Rubinow, J. Fluid Mech. 1976; https://en.wikipedia.org/wiki/Slender-body_theory). In effect...
The LOBPCG algorithm finds eigenpairs of the generalized eigenproblem $$ Ax = \lambda B x $$ where $B$ is symmetric and positive-definite, $A$ is symmetric. One of the features that makes LOBPCG so interesting is the fact that one can use preconditioners of $A$ to speed up convergence. When applying LOBPCG to the FEM-d...
Let's take the heat equation. We have a time derivative and spatial derivative. How to discretize the spatial derivative using Chebyshev spectral method and convert it into DAEs? Like in the form of $ F(\dot{x}(t),x(t),t) $ $$ \frac{\partial u}{\partial t} = \frac{\partial^2u}{\partial x^2} $$ Assuming boundary conditi...
I'm trying to solve a differential algebraic equation in Julia's modelingTookKit.JL, where the vector field has the form f(X) = 0. I found an example of a DAE in the below link modelingToolkit.JL DAE](https://benchmarks.sciml.ai/html/DAE/ROBERDAE.html) with follwing code. However, when I replace say D(y₁) ~ -k₁*y₁ + k₃...
I would like to evaluate the chi-square of the form $\chi^2=v^{T}C^{-1}v$ where $v$ is a column vector and $C$ is a covariance matrix. Both $v$ and $C$ are known and $C$ is a $740\times740$ matrix. All quantities involved are real valued. The straightforward fastest way I know is to compute the solution to the equation...
$$ argmin(x,y)=x^2+y^2+2y $$ $$ s.t.\ \ y=|x-10| $$ How can I convert the absolute value constraint to the constraint matrix (GX<=h, AX=b) in cvxopt?
I am trying to formulate a convex optimization problem using CVXPY. Everything works, except a constraint that does not seem to follow DCP rules. Let $D \in \Bbb R^n$ be a decision variable and let $Q$ be another decision variable that is derived from $D$ using the following constraint, Q = cvxpy.pos(D) I am not sure ...
I have a simple square mesh, and a curve (discretised by another mesh) inside it. Here a picture worths thousand words. What I want to achieve is to find, for every cell $K$ of the circular (discretised) grid, I want to get the intersection points with the cells T of other grid. Here they are marked with a red dot. Wh...
I wanted to attempt an implementation of a finite-difference-based solver for the 2D elctrostatic Poisson equation when metallic objects are present. Also, I hope to take as input, the location of charges and their magnitude. For the sake of simplicity, I consider a rectangular domain, inside which I attempt to solve t...
I am trying to numerically solve the advection equation $y_t + y_x = 0$ using a the "classical" Runge-Kutta 4 explicit timestepping method, along with a left-hand finite difference approximation for the x-derivative, in MATLAB. Specifically: $\frac{d}{dt}y(t_i,x_j)= -\frac{y(t_i,x_j) - y(t_i,x_{j-1})}{dx} = f_j(\vec{y}...
I am used to solve parabolic or elliptic non-linear PDE and the common methods to tackle non-linearity are Picard's iteration and Newton's method. I am a bit confused by the way things are done with hyperbolic equations. For example, with the classical inviscid Burgers' equation in the non-conservative form: $\begin{al...
I was redirected here from physics stack exchange where hopefully my question is more appropriate. Per my advisor, I have read the textbook Chaos, an introduction to dynamical systems by Alligood, Sauer, and Yorke. (side note, I have really enjoyed this book). In chapter 5, the numerical calculation of Lyapunov exponen...
I have a discretized 2D mesh over which I calculate eigenvalues and eigenvectors of some Hermitian 2 x 2 matrix at each point along a closed loop parameterized by parameter t. The eigenvectors are usually complex-valued. I then calculate a quantity z(t) using the eigenvectors. The complex-valued number z(t) is calculat...
Does anyone know a library that implements sparse direct solver working in already open omp parallel region? The only library that I know that works with this requirement is Pardiso7.2 worth ~8K USD for a single-user license. Intel MKL Pardiso and MUMPS solvers assume the execution environment is single-threaded, so wh...
I am trying to solve an equation for chemical advection of a fluid in a porous media with this equation: $\begin{align} \frac{\partial (\phi(x,t) C(x,t))}{\partial t} = - \nabla . (\vec{q(\phi, t, x)} C(x,t)) \end{align} $ with $\phi$ beeing the porosity, C the concentration of an element, and $\vec{q}$ the fluid flux...
I'm new to C++ programming. This seems a common error but I can't seem to solve: I'm trying to use the gsl library, with no luck: using /usr/bin/g++ to compile, for instance, the following minimal (supposed to be) working example (available here). #include <iostream> #include <gsl/gsl_linalg.h> int main() { cout <...
Is there an "Unspoken Tradeoff" in Convergence Rates for "Quasi-Newton Methods vs. Gradient Descent"? As a quick summary: Gradient Descent based algorithms try to find the minimum of the function they are optimizing by repeatedly using information obtained from the First Derivatives Quasi Newton methods (e.g. BFGS) t...
Is there any method to linearize the following optimization problem? \begin{align} min_{x,y} &~~ c~[x; y] \\ st &~~ \sum x\leq \alpha_1 \\ &~~ \sum |y|\leq \alpha_2 \\ &~~ \sum y= 0 \\ &~~ x+|y| \leq 1 \\ &~~ (x,y)\in \{0,1\}*\{-1,0,1\} \end{align}
I need to solve a linear system of the form $(\mathrm{Id} + \mathbf{J})\mathbf{x} = \mathbf{b}$ for $\mathbf{x}$ and I also need to compute the operator norm of $\mathbf{J}$ (i.e. the largest singular value). The matrix $\mathbf{J}$ has no special structure other than being real-valued; the vector $\mathbf{b}$ is also ...
I remember there is a software (and its website interface) that can generate numerically stable equation from an expression automatically. To see the problem it tries to solve, let’s take a look at a simple example of $f(x) = \log(1 + \exp(x))$. If $x$ is a relatively large number (e.g. 800), $\exp(x)$ could be very la...
Can anyone help me prove that, if the residual $r_0 = b-Au_0$ can be written as a linear combination of $k$ eigenvectors of $A$, then the CG method will converge to a solution $x^{*}= A^{-1}b$ in at most k steps. With $N=I_n$ and $A$ is symmetric and positive definite.
I need help to know, how can I convert an unstructured 2d mesh for structured mesh? (Software Gmsh version 4.9.3). This is my script in Gmsh. Mesh.MshFileVersion = 2.2; // Geometry //Points Point(1) = {0, 1, 0, 0.3}; Point(2) = {0, 2, 0, 0.3}; Point(3) = {7, 2, 0, 0.3}; Point(4) = {7, 0, 0, 0.3}; Point(5) = {1, 1, 0...
I have an equation like $$ \frac{\partial u}{\partial t} =A\frac{\partial^4u}{\partial x^4} $$ with boundary condition $$ u(x = \pm L,t) = 9; u_{xx} (x=\pm L,t) = 4 $$ I tried to use the method of lines and rewrote the whole PDE equation in the form of $$ \frac{\partial u}{\partial t} = A \frac{ u_{i+2} - 4u_{i+1} + 6u...
I am purchasing a new workstation to run FDS (Fire Dynamics Simulator) simulations, a CFD code for thermally driven fluid flow. Currently, I am using an Ubuntu Linux build with a Xeon E5-2630 v3 @ 2.40 GHz with 8 cores and 16GB of RAM. The total mesh is about 20,000 cells (4.5 by 4.5 by 10cm), divided into 8 meshes, 3...
In the p-adaptive version of the finite element method, elements are allowed to have shape functions with arbitrary different polynomial orders. Therefore regarding a 2D problem with quadrilateral hierarchic shape functions, the polynomial orders of four edge-modes of an element, $p_e^1,p_e^2,p_e^3,p_e^4$, and its inte...
I am used to solving elliptic PDEs of even order. I was wondering what would one do for odd order PDEs. Notably the discretisations of those results in unsymmetric matrices. I tried solving the following simple problem: $$\frac{d^3u}{dx^3}(x) = 0,\, x\in \Omega \quad u(x) = f(x), \, x \in \Gamma_D, \, \partial^{l}_nu(x...
I want to simulate a vibration of a thin plate (the Kirchhoff-Love model) on triangular meshes. Can you advise me on an introductory-level review of different elements for thin-plate FEM simulation? I was thinking about Morley elements, but they seem non-conforming (is it really bad? never worked with non-conforming FE...
I was reading the Wikipedia page for "Well-posed problems". Supposedly, if a problem is well-posed, it must meet the following conditions: a solution exists the solution is unique the solution's behavior changes continuously with the initial conditions I can understand why the first two conditions are desirable for a...
Is there a name for the following optimization problem? Is it solvable? \begin{align} \min_{\pmb{u}} & \qquad \frac{1}{2}(\pmb{u}-\pmb{u}^m)^{T}(\pmb{u}-\pmb{u}^m)\\ \textrm{s.t.} & \qquad \pmb{A}(\pmb{u}) \textrm{ is positive definite} \end{align} Here $\pmb{u}\,\in\mathbb{R}^{n},\pmb{u}^m\,\in\mathbb{R}^n$, $\pmb{u}...
I want to solve the advection equation ($v_0 \in \mathbb R$) $$ \frac{\partial f}{\partial t} + v_0 \frac{\partial f}{\partial x} = 0 $$ using 2nd order Runge Kutta like the midpoint rule for the time integration and an upwind (backwards finite differences) for the spatial derivation. Here is a general Runge-Kutta impl...
Suppose I have values of log(P(x_i)), i.e. log-probabilities to events x_i. The probabilities are very small, so that these log-values are of the order of -1e3. I want to compute an expectation value. In order to evaluate the corresponding sum, I need the probabilities P(x_i) themselves so I tried to call numpy.exp. Th...
On an informal level, I have heard the following statements being made: The "Branch and Bound" Algorithm has the ability to provide exact solutions to optimization algorithms, but can take a long time to run. Evolutionary Algorithms can only provide approximate answers, but take less time to run. My Question: Are t...
I work to solve PDE using FEM in the case P2 on Matlab. I try to correctly assemble load vector using quadratic Lagrange shape functions $$b_i =(f,\phi_i)=\sum_{q=1}^{nq}f(r_q,s_q)*\phi_{i}(r_q,s_q)*w_q*det(J(r_q,s_q)).$$ Here is what I did [rspts,qwgts] = Gausspoints(precision); % quadrature rule np = size(p,2);...
How can I visualize 3D data volumes with arbitrary cutting plane on web pages? I could not find a library that allows so.
I want to put (non-dirichlet) boundary conditions inside the code I wrote to solve the 2dim TDSE using the alternating direction implicit Peaceman - Rachford method. $$ (1 + iB\Delta t/2 ) \psi^{n+1/2} = (1 - iA\Delta t/2) \psi^n $$ $$ (1 + iA\Delta t/2 ) \psi^{n+1} = (1 - iB\Delta t/2) \psi^{n+1/2} $$, where $A$ con...
I want to solve this set of 2D advection-diffusion equations of this form in spherical coordinates: $$ \frac{\partial f}{\partial t}=-\mathbf{u}\cdot\nabla f+\eta\nabla^2f+\eta_1(\mathbf{e}_1\cdot\nabla)(\mathbf{e}_1\cdot\nabla)f+\eta_2(\mathbf{e}_2\cdot\nabla)(\mathbf{e}_2\cdot\nabla)f+s_f(g) $$ $$ \frac{\partial g}{\...
In the context of mechanical simulation, where I solve the stationary action principle directly (i.e. $\nabla S = 0$ for some scalar function $S$), I use the wrapper scipy.optimize.newton_krylov to access several different nonlinear Krylov based solvers (in particular, lgmres and cgs). The equations have many solutions...
Introduction I am building an application in which, given a surface and a pair of points on it, an analytic expression of some geodesic arc between them is needed, preferably the one with the shortest length. Furthermore, this parameterized curve, needs to have minimal geodesic curvature. Is there a suggested tool that...
In a previous answer the following identity was presented $$-i \vec \kappa \exp^{[i\vec \kappa \cdot (\vec r_j - \vec r_i)]} = -\vec \kappa \sin[\vec \kappa \cdot (\vec r_j - \vec r_i)] \, .$$ Why does it hold?
I am in need of some help to valdate a consistency test with a finite volume method solver. The idea is the following: Based on the method of manufactured solutions (MMS) I am supplying the analytical solution, $\mathbf{x}$, I am letting the solver assemble the matrix, $\mathbf{A}$ from discretization, and I am supplyi...
I'm learning about ADMM by reading Boyd's paper Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers. The paper says that ADMM is an improvement over the Method of Multipliers because the latter requires the minimization of the augmented Lagrangian: $L_\rho(x,y) = f(x) +...
Most of my knowledge about numerically solving differential equations is long forgotten. Unfortunately I stumbled upon a physics problem where I need to do exactly that. I'm trying to describe the movement of a freediver during freefall. This is the part of the dive when the diver has negative buoyancy and falls toward...
I want to optimize the function $$\min_{X \in \mathbb{S}^{n}_{+}} \mbox{tr} \left( C^T X \right) + \mbox{tr} \left( X^{-1} \right),$$ of which I optimize the equivalent problem $$\min \mbox{tr}\left(C^T X\right) + \mbox{tr}(Z)$$ $$\text{s.t.} \begin{matrix} \begin{pmatrix} Z & I\\ I & X \\ \end...
I apologise if this is somewhat of a rookie question. So, from my understanding, on a GPU board, far more of the space is allocated to ALUs compared to CPUs which have far more cache available. This should mean that a typical GPU is capable of higher FLOP counts. This I understood to be the advantage of a GPU (in a nut...
I'm working on modeling a shock wave using the Euler equation with an advanced Equation of state and the fifth order WENO scheme. The equation are set up on the form: \begin{equation} \frac{\partial U}{\partial t} + \frac{\partial F(U)}{\partial x} = 0 \end{equation} where \begin{equation} U = \begin{bmatrix}\rho\\ \r...
I am simulating a waveguide using diffractio python library (https://diffractio.readthedocs.io/en/latest/readme.html). The idea is to create a single mode waveguide using wave propogation method. First I create a waveguide that has specific refractive index. Refractive index profile gives the distribution of refractive...
I am working on writing a Chebyshev pseudospectral method (see for example "Chebsyhev and Fourier spectral methods" by John Boyd) to solve for the eigenvalues of differential equations of the form $ \left(a_2(x) \frac{d^2}{dx^2} + a_1(x)\frac{d}{dx} + a_0(x)\right)u - \lambda u = 0$ There are "regular" boundary conditi...
Edit I've modified the equations because they were wrong and I added the whole system, as asked by @Wolfgang I am trying to nondimensionalize a system of partial differential equations similar to 2nd Fick's law, with multicomponents system. The reason is to make it more stable when I will implement it numerically. $\be...
I have a problem when using petsc. I want to solve a series of linear equations. A1x1=b1, A2x2=b2, A3*x3=b3 ... The A1,A2,A3 have the same sparstiy pattern. I want to use MUMPS to solve the system. In order to enhance performance, I want to reuse the symbolic factorization. Here my code for solve a single linear system...
Crossposted on Mathematics SE I have been assigned a group project for an introductory Linear Algebra subject on Finite Difference Methods and sparse matrices. Our professor advised we use Gilbert Strang's Linear Algebra and its Applications and G. D. Smith's Numerical Solution of Partial Differential Equations. Howev...
I know very little about numerical PDE, so I apologize if this equation is ill-formed (and I appreciate any corrections). I am currently learning about Brownian motion. A classic result is that we can use Brownian motion hitting times to solve the heat equation. More specifically, if we consider a nice domain in $\math...
Scipy.odr has a setting for "fit types", including one for ordinary least-squares. This matches with the documentation of ODRPACK (see p. 31, Computational method). However, the package accepts standard deviations/weights in this mode and the weights do affect the fit result: In [1]: from scipy import odr ...: def f...
I am trying to parameterize a CVXPY program as I need to repeatedly solve the problem, but I noticed that when my parameters are complex numbers, CVXPY models the problem in each iteration. For example, suppose I want to solve the following problem: $$ \underset{\mathbf x}{\text{minimize}} | \mathbf A \mathbf x - \math...
I am a complete novice to computational physics and am finding difficulty in implementing a code to iteratively solve for a $2\times2$ nonlinear Hamiltonian using Scipy's root solver. I can't seem to find open-source codes that I can take inspiration from and learn by myself. Here is the problem: Consider a single unit...
I need help to understand how to use the result given by an algorithm for constructing an orthonormal polynomial basis over $L^{2}(X)$, where $X\subset\mathbb{R}^2$, with respect to the inner product $(f,g) = \iint_X f(x,y)g(x,y)\,dxdy$. We denote $\mathcal{P}_{n} = \{\text{Polynomials }P(x,y): \text{ total degree of }...
I have a large-scale system of linear equations: $Ax = b$, where $A$ is an $n\times n$ square symmetric positive definite matrix (not sparse), $b$ is an $n \times 1$ vector and $x$ is $n\times 1$ unknowns. The magnitude of $n$ is several million. How much memory does it take to store this problem, say, I use C++ and s...
I implement Crank-Nicolson 2D finite-difference method. I get a matrix A which is banded with 1 band above and below the main diagonal, but also contains 2 additional bands , further apart from the main diagonal, so it is NOT penta-diagonal. A picture showing the structure is below. My matrix is the RHS one. The LHS is...
When it comes to optimizing objective functions belonging to Statistical and Machine Learning Models, there seems to be a general rule: High dimensional objective functions with many parameters are "computationally expensive" to optimize As such, there tends to be two general types of algorithms that are used to optimi...
This is a combination of these two previous questions: How to get ODE solution at specified time points? Stop integration in odeint with stiff ode I need to solve the following differential equation for $f_N$, $$\frac{d}{d t} f_{N}(\mathbf{k}, t)=D(\mathbf{k}, t)\left[f_{N}(\mathbf{k}, t)-f_{N}^{\mathrm{eq}}(\mathbf{...
Framework I am trying to diagonalize the Bogoliubov-de Gennes Hamiltonian. The problem is that the Hamiltonian contains a Laplacian. This could be solved by using a discretized Laplacian. How I tried it If I use a simple Hamiltonian (just the Laplacian) and use eig(l1dd(...,...)) with l1dd the discretized Laplacian (2 ...
I'm trying to recreate Figure 1 in this paper. This requires maximizing equation (19), which I have convinced myself is concave, but I am having trouble implementing it in CVXPY. Here is the code I think is relevant to this question: import cvxpy as cp import numpy as np def tanh_atom(x): return (cp.exp(2 * x) - 1...
In a generic rootfinding problem $f(x) = 0$, we assume that the probability that the root $x$ is a floating point representable is zero. Hence, the best floating point approximation $\hat{x}$ to $x$ gives $f(\hat{x}) = f(x(1+\delta)) = x\delta f'(x) + \mathcal{O}(\delta^2) \approx x\delta f'(x)$ where $|\delta| \le \mu...
I have a question on construction of a Wannier function for tight-binding model. Let's say we consider the tight-binding model of 1D chain with two atoms( site A and B in a unit cell). In k-space we can write the single-particle Hamiltonian in following way: \begin{equation} H = \sum_{k} \Psi_{k}^\dagger h(k) \Psi_k~~,...
This is a repost from another community, it was recommended that I post it here instead. I have been using the Chebyshev collocation method for solving PDEs. In particular to solve a 3D generalized Poisson's equation. One of the problems I am facing is that one of my dimensions is periodic and would require periodic BC...
I have a PDE that contains both the 3rd derivative and 4th derivative. Example shown below $$ \frac{\partial u}{\partial t} =\frac{\partial}{\partial x}(u^3\frac{\partial^3u}{\partial x^3}) $$ $$ \frac{\partial u}{\partial t} =(u^3\frac{\partial^4u}{\partial x^4} + 3u^2\frac{\partial u}{\partial x}\frac{\partial^3u}{\p...
I am looking for some help finding a numerical solution to the shallow water equations: $\partial_tu+\partial_x(u^2/2+g\eta)=0$ $\partial_t \eta+\partial_x(u\eta)=0$. where $u$ is the depth averaged horizontal velocity, $\eta$ is the depth, and $g$ is a constant. Using mathematica's NDSolve I quickly develop a compress...
The full question is: Let {u1, u2,···, un} and {x1, x2,···, xm} be bases for Rn and Rm respectively. Let T:Rn→Rm be the linear transformation whose associated matrix with respect to the above bases is A. Write a program in R such that given two sets of vectors{v1, v2,···, vn}and{w1, w2,···, wm}examines whether these tw...
I was wondering if there is some known way to solve the following optimal control problem \begin{align} \text{min }&\mathcal{J}(\rho,\nu)\\ \text{such that }&∂_t\rho(t, x) = − div_x(((K ∗ ρ)(t, x) + (H ∗ ν)(t, x))ρ(t, x)) \text{ (conservation law)} ,\end{align} where $\mathcal{J}$ is for example a quadratic functional ...
so, I have a symmetric, analytic matrix $\mathbf{H}(x)$ ($x$ is real). Because $\mathbf{H}(x)$ is analytic and $x$ is real, it is possible to find analytic functions for the eigenvectors and the eigenvalues of $\mathbf{H}(x)$. at $x=0$, each eigenvalue $\vec v_i(0)$ is associated with an eigenvalue $\lambda_i(0)$, wher...
So if I've understood it correctly, the Algebraic Multigrid Method (AMG) basically takes a fine mesh, coarsens it, solves the coarse mesh and projects the solution back on the fine mesh. Wouldn't it make sense to skip all the extra steps, just start directly with the coarse mesh, solve it normally and be done with it? ...
In peer reviewed numerical papers, the order of accuracy of finite difference and finite volume for PDEs is computed in multiple norms, usually $l_1$, $l_2$ and $l_{\infty}$, and other times $l_{\infty}$ is used with one of the other two. I guess that the reason for $l_{\infty}$ to be used is that you wanna check that ...
I have a couple of questions with regards to the usage of flux/slope limiters, which I was hoping to get some input. I apologise in advance if my questions are trivial, but flux limiters lie way beyond my research area (up until now) and I am still trying to make sense of all information that is out there. I am trying ...
to perform adaptive refinement in the finite element method according to the explicit residual method, the quantity $$\eta_K^2=h_K^2\left\lVert r\right\rVert_{L_2(K)}^2+h_K\left\lVert R\right\rVert_{L_2(\partial K)}^2$$ must be calculated for all elements of the mesh. For the equation $-\nabla^2u=f$, the norm $\left\lV...
Suppose I have a set of $N$ points of shape $N \times D$, where $D$ is the dimensionality. I want to compute the average Euclidean distance between all points, as well as additional moments such as the variance, median, and percentile boundaries. Is there a way to calculate or estimate these quantities without finding ...
Ive take a course in computational physics and was asked to implement some numerical methods to solve ODES. I was reading up on the algorithms described in the textbook: NUMERICAL RECIPES IN FORTRAN. I dont really understand what the following parameter in rkqs is needed for as shown in the textbook. It seems to be say...
Actual Problem: I want to assess the difference in two text rewrites: it can be fine today => today, it can be fine Simplified Problem: [1, 2, 3, 4, 5] => [5, 1, 2, 3, 4]. (Note: it could actually become [6, 2, 3, 4] for example) Goal: Find some difference score that assesses the global new order, and the local new ord...
I have three 1D arrays, which represent radius, height, and an intensity measured at that point. I have plotted these to create a 2D contour map. A simple example of the way in which the data is stored is below: import numpy as np import matplotlib.pyplot as plt x = [1,1,1,2,2,2,3,3,3] y = [1,2,3,1,2,3,1,2,3] intensit...
I do hydrodynamics simulations with Fortran and recently I met with this issue: I have a single-precision array b of length n=512**3, and I wish to compute the root-mean-squre of its elements. All I do is s=0 do i=1,n s=s+b(i)**2 enddo and then compute sqrt(s/n). I found that it makes about $30\%$ difference in the ...
I am trying to do linear regression on the following conceptualized problem. I have a set of data in pairs $(x, y)$. I know that $y$ is bounded by a linear function $f(x) = mx + c$. I want to estimate this upper bound. Following are visualization of the data generated for two values of a third parameter. As you can s...
I am using the mixed finite element method (MFEM) to solve the Poisson equation: $$\Delta h = 0,$$where $h$ denotes hydraulic pressure. The MFEM could determine the normal flux rate, $q_n$, through the interfaces between two adjacent grids, and the $q_n$ reads $$q_n=\frac{\partial h}{\partial n},$$ where $n$ is normal ...
The numerical method that I'm implementing stores various fields in various elements of an unstructured triangular mesh. Data may be stored in cells, nodes and even edges of the mesh. For a parallel implementation I need to distribute all the mesh elements among processors. There are well known approaches to the proble...
Quite broad question, Currently building own Poisson solver subroutine for CFD solver. Works smooth, the goal is to generalise the input and make it flexible. Description of also: Memory allocation. Filling source right hand side $-\Delta u(x,y) = f(x,y)$ function of Poisson equation. Filling sparse matrix with inner ...
I am looking for a semi-Lagrangian method for advection with a non divergence free velocity field. The equation is \begin{align} \frac{\partial C(x,t)}{\partial t} &= - \nabla \cdot (\vec{v}(x,t) C(x,t)) \\ C(x, 0) &= C_0(x) \end{align} I've solved that using the formulation in this paper [1], which describes a quasi-m...
I am aware of creating an identity matrix in Eigen if the number of rows and columns are known. How do we create them dynamically when the size is not known? An example would be useful. Thanks.
I want to solve Navier-Stokes eq with Dirichlet boundaries using a pseudospectral method. All of the references I encountered used Chebychev transform to do this. But why can’t you use sine transform?
Given a polynomial of degree n and a list of putative roots $\{r_i\}_{i=1}^{n}$, we can verify that all the putative roots are indeed correct by $n$ applications of Horner's method. Hence verifying the solution requires $\mathcal{O}(n)$ storage and $\mathcal{O}(n^2)$ floating point operations. Now, if we use the method...
I'm trying to solve a generalized eigenvalue problem. I have two matrices $H$ and $S$ such that: $$ HX=λSX $$ I need to find the eigenvalues $\lambda$. The matrices $H$ and $S$ are real, asymmetric, contain positive and negative decimal numbers, and (can be) singular. I am using MATLAB and have tried two different appr...
I'm solving a system of coupled ODEs using Euler integration for simplicity. To make this concrete, please see the (extremely simplified) minimal working example below in Python. Imagine we have a box that initially has 0 mass and 0 energy. At each timestep, we add some mass to the box from the outside. Some fraction o...
I am currently learning the usage of Augmented Lagrangian Multiplier to achieve my equality constraint. I have learnt from the https://en.wikipedia.org/wiki/Augmented_Lagrangian_method that I have two multipliers, $\mu$ and $\lambda$. According to wikipedia, it shows me how I can update my $\lambda$ with any value of $...
I am interested in deriving an accurate, implicit discretization of a nonlinear advection-diffusion equation $$ \partial_t f = \frac{1}{v^2} \partial_v J(f,v) \equiv F(f,v) \tag{$\star$} $$ with flux $$ J(f,v) = C(f,v) f + D(f,v) \partial_v f $$ where $f(v,t)$ is the unknown function of a radial coordinate $v\in [0,\i...