instruction
stringlengths
43
28.1k
I have two equations (coupled), with the variables $T_1$ and $T_2$ and the constant $T_0$, which are (when written unitless, i.e. without prefactors): $$\partial_t T_1 = 1-T_1^3+T_1+\nabla\left(\frac{1}{T_2^{2.5}+T_2^{2.4}}\right)\nabla T_1+\frac{1}{T_2^{2.5}+T_2^{2.4}}\nabla^2T_1$$ and $$ \partial_tT_2=\left(\frac{T_1...
I am looking for examples of numerically finding eigenvalues/eigenfunctions of coupled DEs. If anyone is able to point me towards any examples, preferably with code included, it would be much appreciated.
I have 3 functions which consist of 6 variables $p_1,p_2,p_3,p_4,p_5,p_6$. The value of each function is equal to $x$ (say): \begin{align} f_1 &= \operatorname{sign}(2-p_1) \sqrt{|2-p_1|} + \operatorname{sign}(2-p_2)\sqrt{|2-p_2|} + \operatorname{sign}(2-p_3)\sqrt{|2-p_3|}\cr f_2 &= \operatorname{sign}(p_4-2)\sqrt{|p_4...
This question is a follow-up of https://stackoverflow.com/questions/44718160/solve-a-linear-system-for-fft-coefficients At some time (kt), the FT of the vorticity (omega) satisfies: (1-nu*L*dt/2)fftomega(kt+1)=(1+nu*L*dt/2)fftomega(kt)-fft_J*dt where fftomega is the 2d fft of omega, J(psi,omega) is the Jacobian (see b...
dpstf and dpstrf sometimes give different pivot results. Of course I can read the source code, but I don't get the idea from it. Since pivoting is for stability of the Cholesky decomposition, one of them is more stable. Which and why does the other exist?
I have a very similar problem to the one described in Calculate inverse of dense matrix with entries of very different magnitude. The reason why I am opening a new question is because as far as I understood the answer given to the problem in that question was too specific for the problem considered. My issue is that I ...
The two-level additive Schwarz method (additive Schwarz with a coarse space correction) is often written like this: $$ \mathbf{v} = \sum_{i=0}^N \mathbf{R}_i^T \mathbf{A}^{-1}_i\mathbf{R}_i\mathbf{w} $$ where the term $i=0$ is said to be the coarse space correction. $\mathbf{A}_0$ is the solver for a global coarse grid...
I need to solve the Schrödinger equation with a time dependent Hamiltonian $$i\hbar \frac{\partial}{\partial t} \Psi = \left[-\frac{\hbar^2}{2m}\nabla^2 +\frac{1}{2} k(t)(x^2+y^2) + V(r)\right]\Psi $$ Can anybody recommend me an efficient numerical method or software package for solving the problem. EDIT: This is a su...
I have an eigenvalue problem emerging from the internal vibro-acoustic coupling. The eigenvalue problem is nonsymmetric but it was proven in literature that it results in real eigenvalues and eigenvectors due to the relations between the off-diagonal coupling matrices. The eigenvalue problem reads as, $$A \phi = \lam...
Define a sequence $(\mathbf{y})_{i=0}^N$ in $\mathbb{R}^n$ such that: $$\mathbf{y}_{k+1} = \mathbf{y}_{k} + \lambda \nabla_\mathbf{y} E(\mathbf{y}_k,\mathbf{w}), \quad k=0,1,\ldots,N-1,$$ where $\lambda$ is a constant, $\mathbf{w}\in\mathbb{R}^m$, and $E:\mathbb{R}^{n+m}\to \mathbb{R}$ is some differentiable function. ...
Assumed I have the following equations with the parameters $\vec{A}(z, t)$, $\vec{B}(z, t)$ and the constants $a,\,b,\,c$: $$ \begin{split} \partial_tA&=a\partial_zA\\ \partial_tB&=b\partial_zB+A\cdot B\cdot c \end{split} $$ Now the usual approach is to split the equations for an implicit scheme like $$ \left(\frac{1}...
In oceanography, is there any particular reason why choosing large eddy simulations in stead of RANS (regardless of the type of flow)? In both cases, 2d simulations would be used (shallow water model). What are the pros and contras, in general, of both approaches?
I found this one, but does not work: http://www.karlin.mff.cuni.cz/~hron/warsaw_2014/pl2014_lecture5.pdf
We have a variance-covariance matrix denoted with $X^TX$, where $X$ is the design matrix. In linear regression we can estimate beta coefficients with normal equations like $\hat{\beta} = (X^TX)^{-1}X^Ty$ and we can also compute the variance of betas with $Var(\hat{\beta}) = \hat{\sigma}^2(X^TX)^{-1}$, where $\hat{\sigm...
This is a question about hard-field back-projection as used in x-ray tomography, applied magnetic induction tomography. Al-Zeibak and Saunders have shown that x-ray filtered backprojection can be applied to an exciter and receiver coil, with a straight line of magnetic flux between them along the central axes of the 2 ...
How can I find positive integers $a$ and $p$ satisfying $a^{p-1}=1$ ($\mathrm{mod}\ p^2$)? Let's say $1\lt a \lt 100, p \lt 10^8$.
I am interested in numerically solving the following constrained minimization problem; Find the value of $x\in \mathbb{R}^n$ that minimizes $f$ where $f\colon \mathbb{R}^n\to \mathbb{R}$ is defined as $$ f(x) = \frac{1}{2}(x,A x)-(x,b), $$ for the matrix $A$ being large sparse, symmetric and positive definite, subjec...
Let us consider the conventions on names used in the theoretical derivation of Metropolis-Hastings Monte Carlo as outlined here, for the sake of common nomenclature. What we are building is a step-by-step Markov Chain Monte Carlo (MCMC) algorithm to describe the evolution of a system in an initial state towards a fina...
Computational Science has many more parameters than my previous programming, and I'm finding it difficult to keep track. What's the best way to track them? editing source, commenting-out. Good for trying things quickly, but after some exploration, I've forgotten what the earlier ones were. Much harder when a setup req...
This question is the essence of this one. After we remove all the cruft, we can recast it as follows: Problem: Given $b \in \mathbb{R}^n$, $C\in \mathbb{R}^{n\times m}$, and $g\in \mathrm{Range}(C^\mathrm{T})\subset \mathbb{R}^m$. Find $x\in \mathbb{R}^n$ so that $\| x-b \|$ is minimized subject to the constraint $C...
I have a sparse symmetric matrix of dimension 1393x1393 (8308 no zero elements), with bandwidth 1380. By Cuthill–McKee algorithm, I could achieve a new matrix with bandwidth 89. If we call this matrix B, then I'm interested in calculate the inverse I-rho*B, where I is a diagonal matrix and rho is a parameter updated in...
I have this data plotted on a graph in which all points have the same value on the y-axis, e.g a constant integer "c", while the x-axis is the time in seconds. So, for a c = 25 on the y-axis, there are points on the graph corresponding to values on the x-axis equals to, let's say, 32, 59, 78, 142, 249, 286, 301, 310, ...
I want to solve the 2D poisson problem using the interior penalty discontinuous Galerkin methods: −∇a(x)(∇u)=0 in Ω. The variational formulation is such that : $$a_{\epsilon}(u,v)=\sum_{K\in T_h}\int_K a\nabla u\cdot \nabla v-\sum_{e\in \Gamma_h\cup \Gamma_D}\int_e\{a\nabla u\cdot n_e\}[v]+ \sum_{e\in \Gamma_h\cup \Ga...
The documentation is fairly confusing and I know that I need to keep track of the actual grid location of my data. Writing a python script to convert binary data into this vtk format. I want to leave the legacy VTK behind so that I can utilize the parallelism that XML will give. Any help here is appreciated.
I want to solve a diffusion-convection problem numerically. I start from a PDE of the form $$\partial_t f(x,t) = \partial_x(K(x)\;f(x,t))+\partial_{xx}\;f(x,t)^{m}\;.$$ It is possible to calculate a stationary solution $f_{st}(x)$, which looks something like this $$ f_{st}(x) = (a \cosh(x-b))^c\;. $$ Now I try to simpl...
I am looking for a R package that performs finite element analysis. Is there a fenics or equivalent FEM package for R?
I have a random binary matrix $A$ $$ A=\left[\begin{array}{c c c c c}0&0&0&0&1\\0&1&0&1&0\\1&1&1&1&0\\0&1&1&0&0\\1&0&1&1&1 \end{array}\right] $$ and a permutation of the identity matrix (denoted later as $I_p$) that will filter it. I want to find the best permutation $I_p$ (using row/column swapping) so as to maximi...
I have an image that looks like this (it might appear low res in a browser because it is 16 MB). This image was taken with a scanning electron microscope, but because the equipment is outdated there is a lot of noise within the image. What I would like to do is develop a program (in Java) that would take this image as...
My problem Maximize $$\min_{i} \{\ c_i \cdot \prod_{j \in A(i)} {x_{j}} \prod_{j \in B(i)} {y_{j}} \} $$ Subject to \begin{align} &\sum_{j \in C(k)} x_{j} = 1,\ \forall k \\ &l \leq x_{j} \leq u,\ \forall j\\ &\sum_{j \in D(k)} y_{j} = 1+p,\ \forall k\\ &y_{j} \in \{1,\ p\},\ \forall j \end{align} where $c_i, l, u, p...
I plan on using a Quasi-Newton method (L-BFGS) to minimize a non-linear objective function. $$ f: \mathbb{R}^n \rightarrow \mathbb{R}$$ The gradient is kind of interesting: as the values of the first set of parameters approach infinity, the gradient of the objective function with respect to the remaining parameters wil...
The GMRES method is for solving the linear system $Ax=b$. Given an initial guess $x_0$ and the corresponding residual $r_0:=b-Ax_0$, we have the Krylov subspace $$\mathcal{K}_m:=\mathop{span}\{r_0,Ar_0,A^2r_0,\ldots,A^{m-1}r_0\}.$$ The GMRES method tries to find an approximate solution $x_m$ with the correction $d_m:=...
How can i demonstrate that a LCG has full period? Is there a way to demonstrate it or do I just need to check the parameters(a, c, m)?
I have to deal with FEM and the numerical solution of PDEs a lot. While I'm doing ok when just applying or implementing it, I observe a lack of understanding when authors begin to argue with "Ritz", "Galerkin", "Weak Form", "Integration by parts" and so on. Can anyone recommend me a good book to get some basics in that...
My knowledge of finite difference is very basic so this could be very trivial. I've seen how multidimensional finite difference works for say fluid equations, but they are also dealing with a single variable. How would one solve a coupled multidimensional equation, for example of the form $$a \nabla a = \nabla b,$$ in...
Assumed I have the following coupled PDEs with the variables $A(z,t)$ and $B(z,t)$ and the constants $c_1,\,c_2$: $$\begin{split} \partial_tA&=\partial_zA+c_1\left(A+B\right)\\ \partial_tB&=\partial_zB+c_2\left(A+B\right) \end{split} $$ Now I have seen this algorithm for solving those equations: First, calculate the fi...
I'm using the Levenberg-Marquardt algorithm to fit my data with a Gaussian function: $$ f(x)=a\cdot e^{-\frac{(x-c)^2}{2\sigma^2}}+f_0 $$ $a$, $c$, $\sigma$ and $f_0$ are the fitting parameters. The algorithm correctly computes $a$, $c$ and $\sigma$. Given that $$ \frac{\partial f}{\partial f_0} = 1 $$ and a $\delta \v...
I have a data sample from an accelerometer from my phone (pretty bad accelerometer though). I'm trying to double integrate it in order to obtain the position as a function of time. I'm using a program in Python3 to integrate it, here is the code: nm = input("Filename: ") fil1 = open(nm,"r") i = 0 s = 0.0 fil2 = open("...
Suppose we have the negative, inhomogeneous advection equation: $$\left(\frac{\partial}{\partial x}-\frac{1}{c}\frac{\partial}{\partial t}\right)v(t,x)=u(t,x)\qquad(t\in\mathbb{R}_{+},x\in\mathbb{R})$$ I want to solve it numerically, backward in time and forward in space. Now, I have tried a few schemes without avail. ...
I'm interested in finding the roots of the following equation: $\tan(x) = \frac{2x}{x^2-1}$. It is easily seen that 0 is a root and the roots are symmetric w.r.t. 0. I wonder if an analytical solution is known or how can I find, say, 1000 roots numerically with increasing magnitudes ? I've tried Matlab built-in funct...
My question is quite simple, but the more I look at it, the less content I am. My question is how to do a RK4 method for $y'=y$. At first I would assume the following: $$k_1=y_n$$ $$k_2=y_n+\frac{h}{2}k_1$$ and right here you can actually start to see part of the issue that I have, namely that it seems in the second ...
It seems that the 5th order is the corrector and the 4th order is the predictor. Can RK5 be considered as part of Predictor–corrector method?
Assumed I have the following two coupled equations $$\begin{split} \partial_tA&=a_0AB\\ \partial_tB&=b_0AB \end{split} $$ but I am not sure how to calculate them. One approach is a crank-nicolson approach: $$\begin{split} \left(1-\frac{dt\cdot a_0B_0}{2}\right)A_1&=\left(1+\frac{dt\cdot a_0B_0}{2}\right)A_0\\ \left(1-\...
Consider 2 particles in a 2D plane. There is a long-range interaction between two particles: $$f (r_i-r_j)= \frac{\vec{r_i} - \vec{r_j}}{|r_i-r_j|^3}$$ $$\vec{r_i} =(x_i,y_i)$$ $r_i$ determines the position of particle number $i$ in the plane. Knowing position of particles in the 2D plane and also knowing that distance...
I have attempted to create Poisson-distributed random numbers, seeing that it is not so easy as the simple multiplicative algorithm works accurately only if the mean is less than 500. Using logarithms is slightly slower, but it works at arbitrary mean values. However, it becomes extremely slow if the mean is very large...
For testing I would like to solve the equation $$ \partial_tA=\nabla^2_xA,\,A_0=\sin(x) $$ In order to solve it, I use an implicit solver $$\left(1-\frac{\nabla^2_x}{2}dt\right)A_{n+1} = \left(1+\frac{\nabla^2_x}{2}dt\right)A_n $$ or the Runge-Kutta-method in two different orders. For solving the whole equation I use t...
This question was already asked here and this is a suitable form of the equation for numerically solving. \begin{align*} i\frac{\partial}{\partial t}u_{\ell}(r,t) = \Bigg(-\frac{1}{2} \frac{\partial ^2}{\partial r^2} + \frac{\ell(\ell+1)}{2r^2} + V(r)\Bigg)u_{\ell}(r,t)\quad \quad \quad \quad \quad \quad \quad \nonum...
Let's say I have a random arbitrary geometry, like this one https://ibb.co/dG8fUa (something I just made up). I make one of these in 3D in SolidWorks. I have molecules/particles coming in through the inlet and leaving out of the two outlets. In a standard geometry, like a pipe or square channel, a simple way to impleme...
Note: Thanks to comments, I realized that I have two problems, each which can be described more clearly on its own. This revised question covers the first. I would like to solve $$ -\Delta u - 1=0,\quad u(0,y)= 0,\quad u(1,y)=0 $$ over a rectangle using alternating Schwarz. The following is my mesh, where the small d...
Hailing from the scicomp community recently getting into computer-graphics, I have noticed that the scicomp communities talk about mesh-based methods like FDM, FVM, FEM, etc, vs meshfree or meshless methods like SPH (though I like to call them virtual particle methods), but I've never heard them talk about Eulerian app...
I have a set of three coupled autonomous equations: ${y_{1}}\prime = y_{1}(\frac{\Omega_{m}}{y_{1}^3} + \frac{y_{3}^2}{6.0} + \frac{V(y_{2})}{2.H_{0}^2})$ $y_{2}\prime = y_{3}$ $y_{3}\prime = -3\frac{y_{1}\prime}{y_{1}}y_{3} - \frac{1}{H_{0}^2}\frac{\partial v(y2)}{\partial y_{2}}$ And I have used the following code to...
As per wikipedia, scientists have not been successful to accurately predict the whether which is 2 weeks ahead. Here is the excerpt: The atmosphere is a chaotic system, as a result, small changes to one part of the system can grow to have large effects on the system as a whole.This makes it difficult to accuratel...
In a software project that I'm working on, certain computations are vastly easier for dense low-rank matrices. Some problem instances involve dense low-rank matrices, but they're given to me in full, rather than as factors, so I'll have to check the rank and factor the matrix if I want to take advantage of the low-ran...
In case of global temperatures we are interested in aggregate values rather than local distributions. Is this the reason we can accurately predict one but not the other?
Consider a potential/poisson equation on a very large, complicated geometry. Currently, an self-written FEM and linear solvers from NumPy are used. Performance is, of course, not good enough for larger problems. I'd like to switch to PETSc and use algebraic multigrid preconditioners. Surprisingly, I could not find good...
Consider a problem where space is filled with a liquid and a solid phase, with a large, complicated geometry. On each of the phases, there's an electrical potential/poisson equation. The equations are coupled by a nonlinear surface current through the phase boundary. Currently, an FEM is constructed for both phases and...
I have an equation system, constructed as $$\begin{split} \partial_tA&=f_1(A)\cdot f_2(B)\\ \partial_tB&=f_3(B)\cdot\partial_tf_4(A) \end{split}$$ with $f_1,\,f_2,\,f_4$ and $f_3$ nonlinear functions. One idea I had was to use the forward difference for $\partial_tf_4(A)$, i.e. $$\partial_tf_{4,(n)}(A)=\frac{f_{4,(n-1...
I have a rather long expression (https://pastebin.com/jUsxdCCs) that is an analytical solution of a set of differential equations generated symbolically from Maple. I need to solve a set of equations like this in C, in a 32-bit system. The long expression has a variable omega2, which when substituted leads to a number...
I'm playing around with dynamic programming and need to calculate a multidimensional integral $E[V(W)]$ where we assume $W$ has a log normal distribution. I was looking at the following example in this pdf, section 9.4.3 on page 83. To give some background (I summarize from the section): The example is from economics a...
The question is in the context of iterative numerical solution of large PDE systems with Finite Differences or Finite Elements: Stating the Poisson equation with Neumann boundary conditions will lead to a singular system because it is invariant when adding a constant function. An often proposed option is to just "pin" ...
I have following system of coupled Partial differential equations. How can I solve the system by Maple? \begin{align} m_1\frac{\partial^2 u_1}{\partial t^2}+A_1\frac{\partial ^4u_1(x,t)}{\partial x^4}+k(u_1-u_2)=F_1(t) \delta(x-x_1), \end{align} \begin{align} m_2\frac{\partial^2 u_2}{\partial t^2}-A_2\frac{\parti...
I need an efficient way to numerically find the first $n$ positive roots $\lambda_n$ of the transcendental equation $$ \dfrac{J_0 (\lambda_n r) Y_1 (\lambda_n) - J_1 (\lambda_n) Y_0 (\lambda_n r)}{J_0 (\lambda_n r) Y_0 (\lambda_n) - J_0 (\lambda_n) Y_0 (\lambda_n r)} = \dfrac{\delta}{\lambda_n}$$ where $\delta$ is a co...
The issue I have is having to compute the derivative (in real time) of the solution produced by ode45 within the events function. Some pseudo-code to explain what I'm mean is, function dx = myfunc(t,x,xevent) persistent xevent % xevent is the solution at the event dx(1) = x(2); dx(2) = complicated function of x(1),x(2)...
I read the way of storing the five or seven point laplace matrix for some poisson problem but I don't understand how can i multiply, add and subtract this stored sparse matrix by a vector or another matrix? The way says that we just store the diagonal entries which are the coefficients of the i,j,k unknown in adiag m...
For an unconfined aquifer we have this PDE for the water table position( of course after somehow making the original Boussinesq equation linearized ): $$ \frac{\partial^2(h^2)}{\partial x^2} + \frac{\partial^2(h^2)}{\partial y^2} = \frac{2s}{k} \frac{\partial h}{\partial t} - \frac{2N}{k}$$ where $N$, $k$ and $s$ are c...
I have a small 2D system I'm trying to model using a non-linear extension of Darcy's law for fluid flow in porous media. I'm primarily interested in the local flow velocity, not necessarily the pressure, that's later used in the real model I'm working on: The original equation known as Darcy's Law used in ground water ...
I have some Python code containing a couple of for loops, which I would like to optimize by using low-level functions. My first approach is to use numpy.einsum(), but the results don't match the for-loop implementation: ## first term T11 = 0.125 * numpy.einsum('abcd,efab,cdef,abcd,efcd', g[:Nelec,:Nelec,Nelec:,Nele...
$r$: cicle C1's radius $w$,$h$: rectangle R1's edges: $x=w$, $y=h$, $x=0$, $y=0$ $(w>2r, h>2r)$ $S(x,y)$: area of intersection of C1 and R1 when center of C1 is at $(x, y)$ $X$: follows uniform distributed in $[0,w]$ $Y$: follows uniform distributed in $[0,h]$ $X$ and $Y$ is independent. I want to know: What is $E(S(X...
Originally sieve of Eratosthenes requires a lot of memory. This algorithm is my attempt to limit the memory usage. In fact it requires ln(N) memory (for each found prime number we keep last crossed number). Amount of operation (sum and compare) is still limited by sequence N/2 + N/3 + N/5 + N/7 .... + N/Pk = O(N log l...
Consider the unit circle $x^2 + y^2 = 1$, it also represents the solution to the ODE $$ x + y \frac{dy}{dx} = 0; y(0) = 1 $$ Suppose we don't know how to solve the above equation analytically (there are more complex cases where analytical solution is impossible), a finite difference discretization gives: $$ y^{n+1} = y...
My background is mainly engineering and applied research and I have been a developer or some CFD software, but mostly at high level without worrying about linear solvers and the like. This has been changing lately, has we have been wishing to integrate PETSc without our own software instead of using our own in-house s...
I am curious if it is possible to request less than a node using SLURM. For example, if I use the commands, #!/bin/bash #SBATCH --job-name="name" #SBATCH --output="name.%j.%N.out" #SBATCH --ntasks 1 #SBATCH --time=00:30:00 will SLURM automatically reserve an entire node for me, or will it try to fit me in on just one ...
I'm using automatic differentiation on a function that contains a sparse nonsymmetric linear system to be solved. I was using BiCGStab to solve this part of the function, but noticed the derivatives produced by the automatic differentiation that were carried through BiCGStab were diverging in some cases. Is there an it...
I am reading "Using MPI (3rd edition)" from William Gropp, where in chapter 4 application section 4.13, it introduces an MPI application Nek5000/NekCEM which is based on spectral element method (SEM) coupled with high-order timestepping to solve the governing IVM/BVM problems. There is one statement about SEM that I d...
This question is quite open, and the actual problem comes from something you would probably consider an everyday niche (something you'd probably take for granted without really thinking about it). However: I may not disclose the actual application's nature, but I found that pizza bakeries and pizza consumers make for a...
I am implementing a finite element solver (in 2D) to solve the generic differential equation : $$-\nabla(a(x) \nabla u) = f$$ Brief explanation By integrating and multipling by a test function, the weak form allows to integrate the stiffness matrix : $$ A_{ij} = \int a(x) \nabla \phi_i(x) \nabla \phi_j(x)\, dx\quad i=1...
What would currently be the best way to share a matrix with the math community? (I'm aware of Matrix Market but it seems the last update was in 2007...)
This question may be more suited for physics.stackexchange, but I saw this post was recommended for StackOverflow or Computational Science, so I'm asking my question here. I am trying to write a program in Matlab to evaluate an expression with fermionic annihilation and creation operators. Define $$\{f, g \} \equiv fg ...
I'm an undergrad who's studying electronics and fields like data sciences and mostly computing seem most interesting to me but have in-depth knowledge in neither. I learnt basic python last winter vacations and have built on it since then. I'm not too sure how further I should keep doing this and hence wanted to know h...
Helmholtz Diffusion equation with reaction term: $$ k\Delta u + u = f ~ \text{in} ~\Omega $$ $$ \nabla u \cdot \mathbf{n} = 0 ~ \text{in} ~\partial \Omega $$ For sufficiently small $k$ (relative to the mesh), there can be oscillations (with Lagrange elements) that return a negative $u$ in some regions, specially when $...
I need to integrate the following function on the line segment from $P_{1} = \begin{bmatrix} -2\\-1 \end{bmatrix}$ to $P_{2} = \begin{bmatrix} 1\\2 \end{bmatrix}$: $$\int_{P_{1}}^{P_{2}} 4x + y \ ds$$ This question take part into the implementation of a 2D finite element solver. How I plan to do it Suppose that the f...
I am doing an exercise using MPI to count frequencies of words distributed in several different files following similar steps in this instruction. But I met a problem with step 2. In my implementation, I first sent out locally counted word-count pairs into corresponding processors according to the words' hashcode. At ...
I am using Tchebyshev discretization to solve a system of PDEs. Usually, I map the Tchebyshev space($\xi$, from -1 to 1) to physical space ($x$, from 0 to L) using $$x = (\xi +1)*L/2$$ Now, I also want my grids to be clustered around some point($x_c$) in the domain. Is there any standard mapping that can achieve this?...
I'm attempting to use scipy's spilu routine as a preconditioner and I'm finding bad performance for my application (solving a global linear system arising from a DG discretization of an time-dependent ADR PDE). Before I write tests to tune the options and compute the effect of the preconditioner on the eigenvalues of ...
The finite difference matrix for the first derivative is $\begin{bmatrix} -1 & 1 & 0 \\ 0 & -1 & 1 \\ 0 & 0 & -1 \end{bmatrix}$. The finite difference matrix for the second derivative is $\begin{bmatrix} -2 & 1 & 0 \\ 1 & -2 & 1 \\ 0 & 1 & -2 \end{bmatrix}$. $\begin{bmatrix} -1 & 1 & 0 \\ 0 & -1 & 1 \\ 0 & 0 & -1 \end{...
I'm trying to solve the following equation $$u_t = u_{xx} + u(1-u^2), u_x(\pm 1) = 0,$$ using the Fourier cosine transform. The nonlinear term gives a convolution which I would rather avoid, which is why I wanted to try a pseudo-spectral method. In MATLAB I have the following script (simplified as much as possible) fun...
I am trying to use a combination of JST and ROE scheme for the RANS solution of an aerodynamic problem. I notice that the ROE scheme performs poorly in terms of the convergence in the drag counts for higher angle of attacks compared to the JST scheme. I am now wondering if to run the ROE scheme to a certain degree of c...
I would like to do the following operation: I have a "4D" matrix A and a "3D" matrix B. Both A and B are actually 2D matrices, where for A, each element is a 2D matrix, and for B, each element is a 1D matrix or vector. I would like to, for each element in the 2D floor plan, multiply the matrix on A and the matrix in B....
Let us consider a function $f(r,\theta,\phi)$ that can only be efficiently computed in spherical coordinates. We need its Cartesian gradient. We can implement its analytical spherical derivatives, compute the spherical gradient, $\left(\frac{\partial f}{\partial r},\frac{1}{r}\frac{\partial f}{\partial \theta},\frac{1}...
The context of my question is how to compute high order derivates on direct numerical simulation of turbulent channel flow. It is of particular interest for fluid dynamics and turbulence research. I want to find the coefficients of a B-spline curve given the value of the resulting function on a set of collocatioin poi...
I have a number of evenly-spaced samples of functions that are polynomial in $1/x$ where $x$ is a continuous variable on $x\in\left[a,b\right]$, i.e. $$f(x_i)=\sum_{n=0}^{N} f_n x_i^{-n}.$$ I want to use some sort of local interpolation function like a hat function (linear interpolation), but it is pretty inaccurate (a...
I am solving the initial value problem $$ \frac{d}{dt} (E C_g) = -\delta, \quad E(0) = E_0, $$ for $E$, where $E$ and $C_g$ are functions of $t$, $C_g$ is completely known, and $\delta$ is a function of $E$. Using the following first order approximations for derivatives, \begin{align*} \frac{d}{dt} (E C_g) = E' C_g + E...
I have two matrices $A, B$ coming from a finite element discretization of a system of partial differential equations. $A$ represents the system matrix and is symmetric and indefinite. $B$ is symmetric positive definite and is used as a preconditioner. Direct solver is used for computation of action of $B^{-1}$. The pre...
I have the following PDE in 2D: $U_{x} + U_{xx} + U_y + U_{yy} + U_{xy} = f$ where $f$ is a constant. And I'm trying to create a matrix $A$ to solve the PDE through finite differences: $AU = f$. I will invert $A$ such that $U = A^{-1}f$. I have mixed boundary conditions in this form: $0 = a_0U + a_1U_{x} + a_2U_{xx} + ...
I'm looking for a good Matlab package/library for B-Splines approximation. Ideally, it would take knots $t_1, \ldots , t_n$, and data points $g(t_1),\ldots , g(t_n)$, and Produce $$Vg :\,= \sum\limits_{j=1}^n B_i ^k (t) g_i \, , $$ where the $B_i ^k$'s are the B-spline basis of order $k$ with respect to the given knot...
Let $F: \mathbb{R} \rightarrow \mathbb{R}$ be a linear map. I want to evaluate an expression of the type $$F((ax+b)^k)$$ in terms of $F(x)$ for some fixed value of $x$ (I already know $F(x)^r$ for $r=1,...,k$). $x$ is typically small ($0<x<1$), and $k$ is typically about $15$. $a$ is always positive (about $30$) and $b...
(I'm not sure which of math.se / stackoverflow / scicomp.se is the right place to ask this question) I have a C++ code which generates a complex matrix and then calculates its eigenvalues and eigenvectors using LAPACK zgeev. As an example this is one of those matrices: I wanted to test my code so I entered the same ma...
I'm sure this would be a common question, however yet to find an answer for. Suppose I have two, 2D vectors in Python RaceA =[[ Runner ID, Heart Rate, Kilometers Done,], [1234, 67, 50], [1256, 83,64], [1356,92,82], [845,80,18]] RaceB =[[ Runner ID, Heart Rate, Kilometers Done,], [845, 79, 74], [5363, 86,34], [1256,84...
This is a follow up to this question. I have mapped from Chebyshev space to the physical space using the mapping $x = ((1-w)\xi^3 - x_p\xi^2 + w\xi + x_p + 1 )*(L/2)$. When in Chebyshev space I have easily defined the spectral differentiation matrix as follows: $$(D_N)_{00} = \frac{2N^2 +1}{6}$$ $$(D_N)_{NN} = -\frac{2...
I am trying to implement in C or C++ a solution for a fft and Ifft when the signal values are not obtained at a constant rate, making it having a desviation between the values and the periodic ones. I do not know how I can change the algorithm of calculating the fft with synchronized signals as in https://wikimedia.org...
This will be a very general question. I have a 3D finite element code in Python which I would like to extend to handle "large" problems (~10^8 unknowns in the global system). Right now I am using the scipy.sparse library, which gives decent performance for iterative solvers, but I'm finding the following problems: I'm...