instruction
stringlengths
43
28.1k
I am writing a finite element code for my final year project of BS Mechanical Engineering. The geometry is an integration of several parts composed of different materials. I don't have exact values of material properties. However, I do have ranges of them. For example, for Steel1020, Young's modulus varies from 205-215...
I'm trying to use my current GEKKO model with different solvers methodologies. I don't know if I can also use global optimisation solvers as GA, Simulated Annealing o Differential Evolution. I need that, because I cannot use constraints in my model because I cannot develop my constraints with GEKKO functions (log, sqrt...
I'm learning and improving my Python skills. I did a program in Python about Mandelung constant. But, I'm having kind of a problem. The Mangelung constant is calculated using this sum: $$ V_{total} = \sum_{\substack{i,j,k = -L\\ i, j, k \neq 0}}^L V(i,j,k)= \frac e{4\pi\epsilon_0} M $$ Or $$M =\sum_{\substack{i,j,k = -...
I have a sparse matrix stored in CSR format. For this matrix, I would like to get the incomplete LU decomposition. I tried to find algorithms which can utilize the CSR format but I could not find anything. All work, papers, software seem to access the matrix by giving row index and column index like for COO format (A[i...
The Lanczos method can be used to obtain extremal eigenpairs of sparse symmetric or hermitian matrices. I know there are several implementations of the Lanczos method (as well as Arnoldi, Davidson, and others) out there, but I am specifically interested in one that returns the tridiagonal matrix, not just the eigenvalu...
I am currently in the early construction process of building a simple CFD model of a rotating planetary atmosphere. The planet should be allowed to tilt significantly, so that a time-dependent source function for heating the atmosphere can also go overhead the poles. Because of this, I have to consider grids other than...
Say we want to find a sparse approximate minimizer to the function $f(x) : \mathbb{R}^d \to \mathbb{R}$. Then in line with the work in the field of compressed sensing, we can instead minimize $$f(x) + \lambda \|x\|_1$$ as a convex proxy/relaxation to the desired sparsity constraint on $\|x\|_0$. But often times optimiz...
I would like to know the command/line in Maple 16 or similar to obtain the second fundamental form tensor for a given metric. I've managed to obtain Rienmann and Ricci tensor, even Weyl, but I can't find anything on the internet that would help me to obtain the K_mu_nu of a generic spherically symmetric metric such as:...
I would like to calculate the following two expressions using Wolfram Alpha: $$z = (x (d^2 + d (4 y - 6) - 8 y^2 + 12 y - 3) + 6 (d - 1) (y - 1) y)/(d^2 - 2 d y + 4 y^2 - 6 y + 3)$$ and $$w = -(\sqrt3 (d^2 (x + 2 y - 1) - 2 d (x (2 y - 1) + y^2) + x (4 y - 3) - 2 y^2 + 6 y - 3))/(d^2 - 2 d y + 4 y^2 - 6 y + 3)$$ where...
I came across the method of multiple-scale analysis and was intrigued, because I am trying to solve a linear ODE with multiple characteristic timescales. When I apply the method as described, say, here, I find that the zeroth-order solution is the exact solution! This is exactly what I don't want, because conventional ...
I am solving a system of nonlinear time-dependent equations using the Newton method in a finite-element-setting, i.e. first I create the jacobian matrix for the current time, and afterwards I try to solve the system (using a GMRES-solver, preconditioned using the AMG-method) to get the solution update. This is repeated...
Suppose $A,B\succeq0$ and $C\in\mathbb R^{n\times n}$. I am hoping to solve an instance of the following optimization problem: $$ \min_{\textrm{permutation matrices }P} \mathrm{tr}(BP^\top AP+C^\top P) . $$ This objective function is convex in $P$, but the constraint forces $P$ to be a permutation matrix. In essence,...
I need to calculate a closed-loop system in Python; specifically, obtain the PID response and then use the output to obtain the system response sample-by-sample with my own loop. For this, I am using a fourth-order Runge-Kutta with an adaptitive step size to solve the state space representation. So far, the only way I...
Recently, I have met a question that a saying goes that for large linear system: iterative methods are required because of memory problem of direct methods. But when I implement some experiments in Matlab, I find a strange phenomenon: I used the Poisson equation in 2D and use Q1 element, grid input is 10, and I got...
i have a large rectangular invertible matrix M (about 5000x5000) and i have a loop in which i do the following for each iteration i (there are about 6000 iterations): i am given a subspace S_i (which in my problem is always a subset of the standard basis; for example, "dimensions 3, and 300, and 3723"; these subspace...
I have a smooth enough injective function $f:[a, b]\to \mathbb{R}$ which I want to approximate by something that can be computed quickly, e.g., a Padé approximant of low degree, $$ \frac{\sum_{j=0}^m a_j x^j}{1 + \sum_{k=0}^n b_k x^k}. $$ At the same time, though, I also need the inverse of the approximating function t...
Can someone suggest a way to get Cholesky factorization of a singular covariance matrix? I need it to match Cholesky on full-rank matrices, ie coordinate order should be preserved. My attempt below was to use ldl routine in scipy, but that gives me factorization on a different ordering, any ideas? import numpy as np fr...
I am trying to replicate the method given in the this paper. I have written a Matlab program which determines the displacement field of Mindlin–Reissner plate theory using Ritz method. The limitation of the program is that the plate should lie on xy-plane. Now I want to extend it to plates that are NOT aligned with an...
From the Petsc manual pages, I fail to understand what the orientations of cones and transitive closures mean. In particular, how can I relate these numbers to the orientation of the length/area/volume of the corresponding mesh components ? How can I retrieve the notion of "relative orientation of a face within a cell...
Let's assume I am working on a 2-D domain on $R^2$, with my coordinates $x \in[-1,1]$, $y \in[-1,1]$ and I want to solve a popular CFD problem, like the shallow water system or the Euler system. At $x=0$ there is some physical feature that I want to resolve really well, so I want to employ mesh refinement around the or...
I am making a toy code in Python to solve the advection equation $$u_t + cu_x = 0$$ with, for example, periodic boundary conditions. Background information The numerical grid is specified like this: # problem parameters lx = 2.0*np.pi # length of the domain c = 1.0 # advecton speed # grid generation nx = ...
I'm using the Barnes Hut method to calculate the magnetic vector potential induced by an applied current. Given as: $\begin{equation} A(r) = \frac{\mu_0}{4\pi} \int_V\frac{\bf{J(r')}}{|r-r'|}dV(r') \end{equation}$ In general this equation can be written as: $\begin{equation} \Phi_i = \sum^N_{j=0} \frac{m_j}{r_{ij}} \en...
I'm solving a quantum mechanical problem, and the quantization condition requires me to solve the equation $$ U\left(\frac12(\ell+1-E), \ell+1, r^2\right) = 0, $$ where $U(a,b,z)$ is the confluent hypergeometric function of the second kind, $r>0$ is a fixed positive real number, and $\ell\geq0$ is a fixed non-negative ...
I have implemented the Jacobi iteration in C++ using a dense vector and a sparse matrix in CSR format. The code is as follows: { T omega = 2.0 / 3.0; std::vector<T> temp = result; for (int niter = 0; niter < maxit; ++niter) { for (int i = 0; i < matrix.get_rowptr()->size...
For a performance-sensitive problem, I need to compute the pseudoinverse of a skinny matrix (#rows = 1000–10000, #cols= 10–20). I already employ the traditional SVD econ method. For some problem sizes, this takes up most of my computational time. Is there any faster method? The matrix is dense, and usually ($A^TA$) is ...
For numerical methods of the Stokes equations, with appropriate boundary: $$-\nabla^{2} \vec{u}+\nabla p=\overrightarrow{0}$$ $$\nabla \cdot \vec{u}=0$$ one may use FDM (finite difference method) or FEM (finite element method) to discretize it, which can both be tranformed into a saddle points system as follows: $$\lef...
We've recently ported our Python/Fortran simulation code to a new supercomputer. Some (not all) of the tests (simulations) that we've run on the new platform yield results that are significantly different from those we got on the "old" cluster. We see ${\cal O}(1)$ numerical differences between output variables on the ...
Motivation: I'm using 2D regular grid (it's actually a quadtree but I can still treat it as a finite difference thing if I weight-average the solution over smaller scale cells for the purpose of estimating Laplacian in the neighbor points) to discretize my Poisson equation and I'd like to solve it iteratively. The disc...
I am looking at the following system of ODEs: \begin{array}{r}{\left[c_{2}(k)-\partial_{\tau}^{2}\right] \varphi_{2}\left(\tau \right)=f_{21}(\tau) \varphi_{1}\left(\tau \right)} \\ {\left[c_{1}(k)-\partial_{\tau}^{2}\right] \varphi_{1}\left(\tau \right)=f_{11}(\tau) \varphi_{1}\left(\tau \right)+f_{12}(\tau) \varphi...
EDIT: We have a coupled system of 10 ode each. The coupling presents in the last equation. I thought about using a matrix 10 by 2 as initial conditions. I also followed a similar question with the same title here, but I still get the same errors ('Too many input arguments.') time = [0 5]; x1_0 = [0 0 0 0 0 0 0 0 0 0];...
i have a time-series and, in analogy with exponentially weighted moving average, i would like to compute the exponentially weighted moving standard deviation or variance in an efficient, numerically stable manner. This is in Octave/MATLAB so vectorized is better than looping. An incremental algorithm for computing weig...
I am trying to understand intuition of ADMM (alternating direction methods of multipliers). It combines dual ascent and method of multipliers. Downside of method of multiplier is the loss of decomposability. Why does method of multipliers lose decomposability?
I am working on the following Stochastic Differential Equation (SDE) in the Quantum Mechanics context: $$dX_{t} = a X_{t} dt + b X_{t} dW$$ where $X_{t}$ is my stochastic varible, $dt$ is my integration time step, and $dW = N[0,1] \sqrt{dt}$ is the Wiener differential. Due to the "quantumness" of this SDE, it's not pos...
I want to use the Numerov method but keep higher-order terms from the Taylor expansions. In the literature, I found the term "Deferred Difference Corrections" for the procedure of first solving the differential equations via the standard Numerov method and afterward adding the higher-order terms. For me, this sounds ju...
An important component of the Cartan KAK decomposition for 2 qubit operations is to diagonalize a 4x4 unitary matrix using orthogonal (not unitary, purely real orthogonal) matrices. That is to say, given unitary U find orthogonal A and B such that A*U*B is diagonal. (Actually, the orthogonal matrices are supposed to be...
someone knows where I can find a FEniCS implementation of Maxwell equations for a dipole or other type of antenna? I mean a dipole antenna with an arbitrary geometry of every 'leg' in the dipole.
I have a data extracted from Comsol on some node points and I know the coordinates of each node. Does anyone know how Comsol calculate the partial derivative from the values at each node and also using the coordinate information?
Suppose I have semi-positive definite matrices $A$ and $C$, is there an efficient approach to get top singular values of X entering the following expression? $$ AX+XA=C $$ My matrices are 4k-by-4k and are known to be low rank, rank somewhere between 50 and 1000. I've been using SVD on top of scipy.linalg.svd(scipy.lina...
I'm looking for references to understand where the numerical instabilities come from in hydrodynamics in general, and notably when the Péclet number: $Pe>1$. I'm using the finite element method. Would you have some references for that, please? Or if you could explain at least the case of the Péclet instability for exam...
I'm using the finite element method (FEM), but my question is quite a global question. It's related to this question but it is not the same. Let's assume we have this equation : $$\partial_t c - u\frac{dc}{dx}=\frac{d}{dx}\Big(D(c)\frac{dc}{dx}\Big) $$ with $u$ a positive constant. and with $D(c)>0$ and $$\lim_{c\right...
Is there an algorithm to evaluate spin-weighted spherical harmonics (swSH) at arbitrary points on the sphere? In particular I am looking for, e.g. a recursion relation to evaluate the "spin weighted Legendre functions" ${}_sP^m_l$, which satisfy the follow Sturm-Liouville equation $ \frac{d}{dx}\left(\left(1-x^2\right)...
I'm trying to write up a small code that, given a set of normal vibrational modes for a molecule, will convert them to localized vibrational modes. To do this I'm following the procedure from J. Chem. Phys. 130, 084106 (2009) where they introduce $\tilde{Q}=QU$ as the orthogonal transformation ($U$) from normal modes (...
I am looking for a very fast and efficient algorithm for the computation of the eigenvalues of a $3\times 3$ symmetric positive definite matrix. The algorithm will be part of a massive computational kernel, thus it is required to be very efficient. I am aware of the algorithm suggested by Wikipedia but I found this st...
The multiphase particle-in-cell (MP-PIC) method is characterized by mapping particle properties from the Lagrangian coordinates to the Eulerian grid. However, the implementation of this method in OpenFOAM solves an interpolated equation on the Eulerian grid only in one "submodel", the implicit packing model, for which ...
In Zabusky and Kruskal's paper about solitons, they derive the following update for the Korteweg de Vries equation (their footnote 6): \begin{align*} u_{i}^{j+1} = u_{i}^{j-1} - \frac{1}{3} \frac{k}{h} ( u_{i-1}^{j} + u_{i}^{j} + u_{i+1}^{j})(u_{i+1}^{j} - u_{i-1}^{j}) - \frac{\delta^2k}{h^3} (u_{i+2}^{j} -2u_{i+1}^{j...
I have the following problem: $ \DeclareMathOperator*{\argmax}{arg\,max} \DeclareMathOperator*{\argmin}{arg\,min} \argmax_{\underset{\lambda_k\in \mathbb{R}}{\sigma_q^2(k)\in \mathbb{R}}} \left[\min_{\underset{q\in \left[q_A,q_B\right]}{n_k\in \mathbb{Z}}} \sum_{k=1}^N \frac{1}{\sigma_q^2(k)}\left(q-n_k\lambda_k\right...
When I use BiCGStab to solve a linear matrix system, I use the relative residual to exit the iteration and output the results. For calculating the relative residual I divide the norm of vector $r$ through the norm of vector $b$. Where $r$ is according to the definition of BiCGStab algorithm and $b$ is the right hand si...
I have been given a convection-diffusion ODE modeling the steady state temperature of a pipe (through which flows a fluid) as $$-\frac{d}{dz}\left(\kappa \frac{dT}{dz} \right)+v\rho C\frac{dT}{dz}=Q(z)$$. Here $T$ is the (steady state) temperature and it depends on the space variable $z$. All other parameters are const...
I'm using cuFFT to do some 2D FFTs on matrices of size 2048x2048 or larger. The FFTs are preceded and followed by various scaling operations. These scaling operations are memory-bound, so they take as long to execute as the FFT itself. I think the best way to accelerate them is to fuse them with the FFT kernel. However...
There are many philosophies in different software engineering disciplines about how libraries should cope with errors or other exceptional conditions. A few of the ones I've seen: Return an error code with the result returned by a pointer argument. This is what PETSc does. Return errors by a sentinel value. For examp...
Say I want a QR decomposition of matrix $A$, where orthogonality of $Q$ is with respect to a generic non-degenerate positive-definite bilinear form $\phi$ (in my case, $\phi$ is "defined" by a finite-element mass matrix). This seems like a standard thing one might want to do, so is there a Python implementation out the...
I already posted it on Physics SE, but maybe this is a better place: I have a 5D integral being calculated with a Monte Carlo uniform random sampling. The issue is that the region of integration is very small and for 100000 points I get only around 20-30 points every time. The function has to be calculated several time...
I have a transformation matrix $K$ which transfers elastic constitutive matrix $C$ between two coordinate systems. According to textbooks such as T.C.T. Ting's "Anisotropic Elasticity", the elastic matrix in the new coordinate system $C^*$ should be $$C^*=KCK^T$$ My question is: If $C$ is isotropic, then $C^*=C$ no ma...
I need to import data from file in order to describe the structure of a network. I used the following: weights = readtable('weights192.txt'); W = weights{:,:}; Now, I need to use matrix W (its elements, its size) in the function ode below. How can I pass the matrix or just the elements I need in terms of arguments in ...
Some numerical debugging led me to the minimal example below. I'm observing relative error of 0.75 on individual elements. Is there a way to estimate/bound this error without resorting to higher precision arithmetic? import numpy as np x = np.array([[11041, 13359, 15023, 18177], [13359, 16165, 18177, 21995], [15023, 1...
Let's say that we have the function $$f(x) = 1- \frac{\sqrt{1 + x^2}}{1 + x^2/2}$$ for small $x$. What I am asking is the following: I am going to solve this function numerically for $10^{-10}<x<1$. To have the best precision, should I use the function $f(x)$ as it is and make the computer solve it or should I expand t...
I want to implement a CUDA solver for the 2D shallow water equations using adaptive timestepping with a Courant number fixed by the user. The algorithm pseudocode looks something like this: while (t < end_time) { evolve_flow_variables(); dt = global_minimum_dt_over_all_elements_in_mesh(); t += dt; } I've seen e...
I'd like to know how Ansys computes the slope (=stiffness matrix) at point x1 in figure. I'm studying the way in which Ansys uses the Newton-Raphson method when there are nonlinearities. In the slide there is the specification that we don't know the real curve F-x, thus I have some problem to understand which slope is ...
When I use the newton's method or hybrid solver in the GSL package to deal with 1-D or multidimensional root solving problems, the code frequently crashes when the solver requests function value outside its domain of definition. For example, to solve $f(x)=0$ where $f(x)$ is only defined at $x\geq0$, even when I start...
Take an image $f$ with some characters on it (below, hjFu3). Let's apply a filter $h$ on it to obtain a second image $g$ where the text is not visible. Is there a way to compute what kind of filter $h$ we have applied ? The aim being that this filter should be applied to decode a new blurred image that was blurred with...
I need to compute the kinetic energy cascade using a finite volume solution in an equally spaced grid. I wonder if it is more correct to first compute the kinetic energy in the space (or time) domain, $E(x,t)=0.5(u(x,t)^2+v(x,t)^2)$, and then apply the FFT to obtain $E(k)$, or applying first the FFT to $u$ and $v$, obt...
Background for the question I am currently working on a Matlab code in which the systems of linear equations $Ax_1 = b_1$, $Ax_2 = b_2$, ... have to be solved. As the matrix $A$ is constant during the simulation, I LU-decompose it once and for all at the beginning and solve the $n$th system as xn = U\(L\bn); At this p...
Many times in fourier approximation we come across integrals such as $$\int_0^1 e^{-\gamma\int_0^xu_0(\eta)d\eta}dx$$ where $\gamma$ is a constant and the data for $u_0$ is provided as a discretely sampled vector. How does one perform integration for such numerical integration?
I am trying to solve the following problem: Given a binary matrix $\mathbf{A} \in \{0,1\}^{m \times n}$ and a vector $\mathbf{b} \in \mathbb N^n$, does there exist a binary vector $\mathbf{c} \in \{0,1\}^n$ which satisfies the following requirements? $\mathbf{c}^\top \mathbf{b} < x$, where $x$ is a given threshold. ...
I need an efficient way to take square root of a matrix which is a sum of diagonal matrix and rank-1 matrix. More specifically it's the following matrix $$A=D-uu'=\text{diag}(u)-uu'$$ Where entries of $u$ are non-negative and $\sum_i^d u_i=1$. This is also known as the covariance of the multinomial distribution with me...
I am currently working on a remeshing algorithm for Abaqus using Gmsh as part of my Bachelors thesis and I seem to be stuck at some point. I am able to remesh .geo and .msh files using the script given in Gmsh tutorial "t13". t13.geo: Merge "myJob5.msh"; angle = DefineNumber[40, Min 20, Max 120, Step 1, Name "Param...
I'm looking at random vectors $z$ of size $d^2$ which can be written as $z=x\otimes y$ where $x$,$y$ are random vectors in $\mathbb{R}^d$ with following second moments known -- $E[XX']$, $E[YY']$ and $E[XY']$. First moments are 0. Given a new vector $\hat{z}=\hat{x}\otimes \hat{y}$, I need to approximately divide it by...
I have an unconstrained minimization problem of many variables for which I know the gradient exactly. I turned to the conjugate gradient method contained in scipy.optimize.minimize (which uses the Polak-Ribiere algorithm), but it throws a LineSearchError when I try to converge the algorithm beyond the square root of ma...
I am searching a solution method for the following equation system of equation systems: Let $A \in \mathbb{R}^{n \times n}$ be an invertible Matrix, $f, b_1, b_2 \in\mathbb{R}^n$ given vectors and $ C_i \in \mathbb{R}$ constants. I am searching for a numerical method to find the solution vectors $x_1, x_2 \in\mathbb{...
Most Riemann solvers I've come across can solve the Riemann problem only under certain conditions such as convexity of the equation of state. But what happens if the fluid enters a metastable state or the spinodal region or the fluid state follows a nonconvex isentrope in the p-v diagram? All the approximate solvers de...
I have a dataset $\{x_i, y_i\}_{i=0}^{n-1}$ where $x_0 < x_1 < \cdots x_{n-1}$ (not uniformly spaced), and, in addition $y_0 < y_1 < \cdots y_{n-1}$. So it feels natural to assume that $y_i$ are samples of an unknown monotonically increasing function. I would like to interpolate these data, but it is very important tha...
How can I use BLAS/LAPACK to compute $$ B^{-1}AB^{-T} $$ where $A\in\mathbb{R}^{n,n}$, $B\in\mathbb{R}^{m,n}$ is full rank matrix with $m>n$, and $B^{-1}y:=\arg \min_{x} \|Bx-y\|_{2}$. In theory, one could compute $$ B=QR $$ with orthogonal $Q\in\mathbb{R}^{m,n}$ and triagonal $R\in\mathbb{R}^{n,n}$ and then $$ R^{-1}Q...
I've done some PCA on my own, and am familiar with the basic concepts of how PCA components are calculated and applied. However, I'm working on a research project and am confused as to how to interpret a common type of graph I've seen across many papers using SPME analysis of volatiles. None of the papers I'd read thro...
I am making my own finite difference computational magnetohydrodynamic code in Fortran 90. Looking at other codes they appear to calculate for example their $x$-derivatives, bb of their variables, e.g. aa like the following: CALL system_clock(tstart, count_rate) DO ix = 1, nx - 1 ixp = ix + 1 DO iy = 1, ny DO i...
I am trying to solve the 2D laplace equation, $\frac{\partial^2 T}{\partial x^2} + \frac{\partial^2 T}{\partial y^2} = 0; \qquad 0 \lt x \lt 1, \quad0 \lt y \lt 1$ Subjected to the boundary conditions, ${\frac{d T}{d x}}|_{x=0,y}=0;$ ${\frac{d T}{d y}}|_{x,y=0}=0;$ ${\frac{d T}{d y}}|_{x,y=1}=0;$ $T|_{x=1,y} = 1; $ I...
Where can I find the manual for software library Libxc for exchange-correlation functionals? Links with domain www.tddft.org don't work.
Can anyone see a way to solve this equation efficiently? $$AXB + X\odot C = D$$ I tried a straightforward solution that involved vectorizing $X$ but that turned out too expensive for my application -- my matrices are all $d\times d$ with $d=1000$ so I'm seeing if there's a way to solve it at a cost comparable to $d\tim...
Given a $k$-order polynomial in two variable $p(x, y)$ defined on a polygon domain $K$. And I want to numerically expand it to the following form $$ p(x, y) = c_0 + c_1 x + c_2 y + c_3 x^2 + c_4 xy + c_5 y^2 + .... $$ Let $\{\phi_i\}_{i=0}^{n_k-1}$ are all the basis with form $x^my^n$, here $m, n$ are non-negative inte...
I have been looking at an interesting book "Pharmacokinetic-Pharmacodynamic Modeling and Simulation" by Peter Bonate on pharmacokinetic models: the models of how medical drugs work their way through the tissues and organs of a human body, etc. The book discusses "mechanistic" models where systems of differential equat...
Suppose I have the system: $$\dot{x} = Ax+Bu\\ y=Cx+Du$$ and the following Hamiltonian matrix: $$H=\begin{pmatrix} A & \frac{1}{2}B^TB\\ -CC^T&-A \end{pmatrix}$$ I want to find the value of $\gamma$ which is the bound of the $H_{\infty}$ norm, so it is the value such that $\left |T(j\omega) \right |_{\infty }<\gamm...
I was curious if anyone could help or provide a reference for the proof to the following lemma Lemma: Let $P_{1}$ be the set of polynomials of the first degree and let $W = w(x) : w \in C([0,1]), w(0) = w(1) = 0\;\text{and}\;w\mid_{(x_{i-1},x_{i})}$ then $W = V_{0}$ and $w(x) = \sum_{i=1}^{n-1} w(x_{i}) \phi_{i}(x) ...
Theoretic part From the theory, in Electrostatics inside a real dielectric material between real conductors, in a simple 1D plane geometry between points $P1$ and $P2$, according to the current density continuity equation, when an inequality occurs between the flow of charges into a region and the flow of charges outs...
Assume I have a linear system of $A x = b$ which I want to solve with Jacobi iteration. Matrix $A$ is given in CSR format. The vectors are dense. The code for Jacobi iteration is quite clear and can be looked up fast in the internet. Now I want to vectorize the code but I do not really find a good way to handle the if...
I have the following non-linear diffusion equation, for $\ z(x,t)$: $\ z_t = -C(\sin(\omega t))^m x^{hm}(hm x^{-1}(z_x)^n + n z_{xx} (z_x)^{n-1}) $ Any advice for numerical (or analytical) solutions?
I am trying to obtain the spatial representation of $u(x)$ (e.g. velocity) from its energy spectrum $E(k)=k^4\exp(-(k/k_0)^2)$, which is given in the frequency domain, provided $|u(k)|=\sqrt{2E(k)}$. I need a real $u(x)$ to use it as initial condition for a simulation using FV. How can I obtain a real $u(x)$ using the ...
I've got a matrix K, with dimensions $(n, n)$ where each element is computed using the following equation: $$K_{i, j} = \exp(-\alpha t_i^2 -\gamma(t_i - t_j)^2 - \alpha t_j^2)$$ ... where $t$ is a sequence of $(n)$ numbers equally spaced within the interval $[-3, 3]$. This matrix is symmetric, so I'd expect its inverse...
I'm trying to perform a $10^6$ timestep electrostatic particle-in-cell simulation on a rather large mesh, with very limited computational resources (a single GPU). Because of the large number of timesteps and the fact that the mesh is solved completely anew for each timestep, this takes a while. In Particle-in-cell bea...
I currently need to solve numerically the following reaction-diffusion equation: $$\partial_tu=\partial^2_xu+u-u^2$$ For this purpose, I use the following numerical scheme (Crank-Nicolson??): $$ \frac{u(x,t+\delta t)-u(x,t)}{\delta t} = \frac{1}{2(\delta x)^2} \left[u(x+\delta x,t+\delta t)-2u(x,t+\delta t)+u(x-\delta ...
With some given $s$ value, let \begin{equation} \begin{aligned} h(\beta)&=\min(\sum_{i=1}^n(Y_i - X_i\beta)^2, s)\\ &=\sum_{i=1}^n(Y_i - X_i\beta)^2-\max(0, \sum_{i=1}^n(Y_i - X_i\beta)^2-s)\\ &=f(\beta)-g(\beta, s) \end{aligned} \end{equation} The problem is: \begin{equation} \min h(\beta) \end{equatio...
Heavily edited question after I realised partly what the problem was I have programmed a simple 2D square finite element solution to the Poisson equation $-\Delta u = f$ The source function integrates to zero and I'm implementing as natural boundary conditions. This leads to a tridiagonal block matrix structure. As f...
This might be a silly quesntion but recently I've been trying to program the eigenface algorithm using PCA, so I arranged the face vectors vertically in a matrix X such as: X = [x1,x2,x3,...,xn]; In this case, what would be the wright way of computing the covariance matrix? cov(X) or cov(X')?
In the context of Monte Carlo simulations, I am trying to learn how I should ensure that the configurations of my system are not correlated for the chosen interval of measurements. I have found out that one way is to compute the autocorrelation function for a relevant observable. Let us suppose we have a system of 100...
My question might seem a bit simple. I am trying to solve a system of ODEs using Runge-Kutta method. I am having difficulty breaking down the equations into a system of first order ones required before applying RK45 to it because there is a third order differential of the same parameter "F" in both equations which I am...
Note, there is already a question here, however the answers don't answer the original question, let alone specific considerations when dealing with nearly in-compressible fluids (water). Another similar question here, but does not speak to water, and really only talks about performance considerations. I'm not too conc...
I found a paper [1] that has a method for computing rise and set times of a satellite given a closed form solution. It is a complicated sinusoidal function and the paper has a method to calculate a single rise set over a single period using newton rhapson method. I want to find a way to calculate all zeros over a given...
I am currently reading the paper PALMPRINT IDENTIFICATION BY FOURIER TRANSFORM by WENXIN LI, DAVID ZHANG and ZHUOQUN XU about identifying persons based on an image of their palm, one version of the paper can be found here. The first step in their identification algorithm consists of aligning and preprocessing the image...
So template matching using correlation is available in a lot of computational packages; OpenCV matchTemplate(), scipy.signal.correlate2d(), IPP CrossCorrNorm, etc. But they all either evaluate offsets for which the template is fully inside the image, or use a boundary condition like padding or wrapping to evaluate offs...
Does Lapack have a routine that, given symmetric $A=A^T$ and $B$, computes the symmetric matrix $B^{-1}AB^{-T}$ (while preserving symmetry exactly)? It would be enough to have this routine for triangular $B$, because of course the first step here will be computing a factorization of $B$ (LU or LDL, according to whethe...
C++ has had the std::valarray class since the C++98 standard. It is meant to facilitate numerical computations, providing the sort of operations one would expect of a class implementing the mathematical concept of a vector space (with minor oddities like operator==, which returns a vector of booleans instead of a singl...
I am using an existing GCC C++ x86 Qt application that filters, displays and stores results computed by some C code. Since the computation by now got too complex for CPUs I intend to port the small C program to some GPU computing platform. So the C code should execute tasks received from the x86 GUI, running them paral...