instruction
stringlengths
43
28.1k
Is solving a $QP$ (i.e.: quadratic program, hence a quadratic objective function with linear constraints) easier than solving a $QCQP$ (ie.: quadratic constrained quadratic problem) with linear objective? I am aware that $QP \subseteq QCQP$ and that $QCQP$ is generally harder than $QP$. Moreover, i am aware that a line...
I am trying to fit supernova data into a scipy.curve_fit function. However, when my code runs, the values of the unknown variables given by popt are exact. Also no covariance matrix is getting produced. The code does not give the correct values for the unknown variables $K_1$, $K_2$, $\alpha$ and $\beta$. The model th...
I am trying to fit a differential equation to some data and obtain the parameters of the underlying model. This requires me to try out various parameter values, but this often gives me an ODEintWarning. Having a few of these warnings is OK, but having too many will cause my program to crash quite often (I work using Sp...
Vlasov equation is pretty straightforward It would be easy to solve with Fem packages like firedrake, but in my case I have 6d distribution function: it depends on 3d vector of spatial coordinates and 3d vector of impulses. In plasma physics particle in cells is the method of choice for such problem, but I'd like to ...
In Fong, Saunders: LSMR: An iterative algorithm for sparse least-squares problems, section 3.3 one reads Since only the last diagonal of $\tilde{R}_k$ and the bottom 2x2 part of $\hat{R}_k$ change each iteration, this estimate of $x_k$ can again be updated cheaply. The pseudocode, omitted here, can be derived as in se...
I am trying to modify my simulations on population dynamics using the split-operator method from 2D two-level real Hamiltonain $$H_{2D} =T(x,y)\otimes1_2 +\begin{pmatrix} -z & y\\ y & z\\ \end{pmatrix},$$ to a complex 3D two level Hamiltonian $$H_{3D} =T(x,y,z)\otimes1_2 + \begin{pmatrix} -z & x+iy\\ x-iy & z\\ \end{...
If I want to build a solver for this following problem: 1. There is stagnant water governed by the Navier-Stokes equation in the domain. 2. Air bubbles (µm to mm in size) are produced from an arbitrary point within the domain, and their movement will obey NS-equation as well. 3. Particles (having similar sizes like the...
The common form of initial value problem that can be solved using ODE integrator is $$ \mathbf{x'}=\mathbf{g}(\mathbf{x}, t) $$ where $\mathbf{x'}=\partial\mathbf{x}/\partial t$. The initial conditions $\mathbf{x}(t=0)$ are given. There has been a lot of prewritten solver that can be used to solve the equation above (e...
I wanted to solve a 1D potential barrier problem. It seemed easy enough to do: set a travelling wave coming from the left, part of it gets reflected by the barrier, and part of it gets gets transmitted on the right: $$\Psi(z) = \left\{ \begin{array}{ccc} e^{ikz} + r e^{-ikz} & \mathrm{if} & z<=0 \\ te^{ikz} & \mathrm{i...
I am a beginner in programming. I need to program a mutualism model of two species in python that would solve and graph using the following equations: $$ \frac{dN_1}{dt} = N_1(r_1 - e_1N_1 + \alpha _{12} N_2) $$ and $$ \frac{dN_2}{dt} = N_2(r_1 - e_1N_2 + \alpha _{21} N_1) $$ $N_1$ is the population of Species 1. The v...
There are a lot of books about FEM, which are really friendly to engineering students. Through these books, we can know how to use shape/test functions based on the variational principle. But I'd like to solve the mixed formulation of Poisson equations (i.e. Darcy equation), which reads $\mathbf{u}=-k\nabla h$ and $\na...
For my research, I need to integrate the following function: $$ W(z)=\int_0^{\infty}dx\ w(x,z)\\ =\int_0^{\infty}dx\frac{e^x}{(e^x+1)^2}\log{\left(\frac{e^{z^2/4x+x}+1}{e^{z^2/4x+x}-e^x}\right)}\\ =\int_0^{\infty}dx\frac{e^x}{(e^x+1)^2}\log{\left(\frac{e^{z^2/4x}+e^{-x}}{e^{z^2/4x}-1}\right)} $$ where $z > 0$. The nume...
What is the algorithm which transforms the octree/quadtree into a grid? i.e, getting the adjacency or connectivity between the cells in order to be able to perform interpolation, gradient,...etc. I am trying to do it on the fly. I ended up using the following procedure: Check if a voxel is to be divided. If true, crea...
The square root function for an old (pre-IEEE floating point, no hidden bit) mainframe (the Soviet BESM-6 works as follows: Making sure the argument $X$ is non-negative Splitting $X$ into the exponent $E$ and the 40-bit mantissa $M$, the latter being in $[0.5, 1.0)$. Computing $T := -0.204405847 M^2 + 0.890194099 M + ...
I have the following problem $$\underset{Z}{\min}\left\|X-AZBH\right\|_F^2+\left\|H-B^{T}Z^{T}A^{T}X\right\|\\ \text{subject to } Z^{T}Z=I$$ How to solve the variable $Z$?
I have a set of data $(x_i,y_i,y'_i)$, $i=1,\dots,N$ and I want to fit an interpolating curve $f(x)$ which matches both the data $y_i$ and the first derivatives $y'_i$ at the nodes $x_i$, \begin{align} f(x_i) &= y_i \\ \frac{d}{dx} f(x_i) &= y'_i \end{align} At first I thought that piecewise cubic Hermite interpolation...
I am experimenting with ways to call compiled programs from Python. My primary interest is iterative optimization methods, so I'm testing an implementation of Newton's method to solve a logistic regression problem. In my tests, a Fortran implementation with f2py is more than 4x faster than an implementation using C++, ...
Feasibility of synthetic, simulated predictions w/o matching against empirical physical measurement? This has puzzled me lately. So, while it's sometimes common to approach modelling and model development by making empirical observations and measurements first (e.g. small experiments). And then developing a model that ...
I need help. Do you know such a library for 3D triangulation - CGAL? How to get from it the order of joining the vertices to enter into your variable? Found nothing on the official site. Thanks!
What's the relationship of machine learning and mechanical simulation? Particularly, machine learning is about learning from a large sample and predicting based on filters tuned on that. Mechanical simulation is about using physical laws and seeing what numbers are produced using those. If one deep learns mechanics, th...
I am trying to model the 1D advection-diffusion equation: $${\partial c \over \partial t} = D_c{\partial^2 c \over \partial x^2} -u{\partial c \over \partial x}.$$ With Robin boundary conditions that has a total flux BC at the left boundary (x=0): $$uc-D_c{\partial c \over \partial x}=uC_f,$$ and a zero-flux BC at the ...
I'm trying to solve the Schrödinger equation for the hydrogen atom in the following form numerically: $$\left[-\frac{\hbar^2}{2m}\frac{d^2}{dr^2}+V(r)+\frac{\hbar^2l(l+1)}{2mr^2}\right]R(r)=ER(r).$$ With the Coulomb-Potential $$V(r) = -\frac{e^2}{4\pi\epsilon_0r^2}.$$ By introducing the dimensionless variables $x = r/a...
Given two sets of points $p_{\text{in},i}$ and $p_{\text{out},j}$ inside and outside of what I intuitively call a "region", I would like to estimate and describe the boundary of this region. Two kinds of answer are welcome: A parametrized description of the boundary A estimation function that predicts whether a new po...
I've asked this at stackoverflow but maybe this community will have a better idea of the answer. I'm currently trying to develop a function that performs matrix multiplication while expanding a differential equation with odeint in Python and am seeing strange results. I have the below matrix of values and function that...
I am coding a function to obtain a randomized time-series from a given $\frac{1}{f}$ law. The randomization is obtained by introducing a random phase in the function. I experience a problem in the simulated time-series, the values systematically rise. I suppose it is something related to the definition of the function ...
I found out the conserved current for harmonic oscillator with angular frequency 1, particle falling in gravity close to ground ($g=1$) using maple. I'm unable to understand the result: $$J[t](t, x(t), \frac{dx(t)}{dt}) = F1(x(t)^2 + (\frac{dx(t)}{dt})^2, -arctan(x(t)/\frac{dx(t)}{dt}) + t)$$ For particle falling und...
I have the following code from scipy.optimize import toms748 from scipy.integrate import solve_ivp def f(r): return lambda x: x-r def E(t,r): return -toms748(f(r),r-1,r+1) sol=solve_ivp(E,(0,10),[1]) When I run it I get the following error Traceback (most recent call last): File "C:\Users\User\Documents\Pro...
I have a linear system $Ax=b$ resulting from a finite element discretization of the Poisson equation. I am applying an IC0 (incomplete Cholesky ($LDL^T$) with the same sparsity as the original matrix) preconditioned conjugate gradients solver to it. However, when this system grows large enough I occasionally get negati...
I have the wave equation $$u_{tt} = 4 u_{xx}$$ with the boundary conditions $$u(0,t) = u(L,t) = 0\,,\quad x \leq 0 \leq 2\pi \,,\quad t\geq 0$$ and initial conditions $$\begin{align} &u(x,0)=\begin{cases}1 & \text{for} \quad \pi-1 \leq x \leq \pi +1 \\0 &\text{otherwise} \end{cases} \\[0.5em] &u_{t}(x,0) = x^2sin^2(4...
I have a set of points that resembles more of an ellipse than a circle. I implemented the optimization formulation below and the solution gives a circle. I tried with various initial values, still to no avail. Have I overlooked or mistaken something? $$ \begin{align} \min_{r_{maj},r_{min}} \quad & \pi r_{maj}r_{min} \\...
I am trying to simulate the following equation using FDTD $ \left(- \partial^2_t + \partial^2_x + V(x) \right) \psi(x,t) =0 $ subjected to the initial conditions $\psi(x,0) = f(x),~ \partial_t \psi(x,0) = g(x)$, the boundary conditions being that it is completely outgoing on the right boundary, and completely ingoing a...
The aim is to solve the below equations and plot $m$ with time, i.e. $\frac{dm}{dt}$ $k$ is unknown and needs to be estimated. For the parameter estimation, the below values in the table for m versus t can be used. This is a dummy dataset, as I would like to get an idea if this problem is solvable. If needed, an initia...
The test functions of general finite elements are like interpolation functions (if my understanding is correct). But how about test functions of Raviart-Thomas elements? Let's raise the $RT0$ element as an example. The test functions of the three edges are $\phi_1 = \sqrt{2}\left(\hat{x_1} \quad \hat{x_2}\right)^{T}, \...
I have to give a presentation on unsupervised learning in 2 days, and I have to explain/show the equivalence between Hebb's learning rule (or Oja's rule to be more specific) and PCA. The thing is that I haven't taken a linear algebra class yet, and therefore I haven't been able to understand any of the proofs I came ac...
I implemented Node-To-Surface contact algorithm (Wriggers, Peter, Computational contact mechanics., Berlin: Springer (ISBN 3-540-32608-1/hbk). xii, 518 p. (2006). ZBL1104.74002.). The code is done by first forming the contact element, comprising of a slave node on the ball and a master line of the base. In the example ...
We can use the $RT0$ to solve the Darcy equation, i.e. $$k^{-1}\mathbf{u}+\nabla p = 0, \text{ in } \Omega,$$ $$-\nabla \cdot \mathbf{u} = 0, \text{ in } \Omega,$$ $$p = p_D \text{ on } \partial\Omega,$$ $$\mathbf{u \cdot n} = 0 \text{ on } \partial\Omega, \tag{1}$$ where $\mathbf{u}$ is the velocity, $k$ is conductivi...
In Maple, I have a function $f(x(t),y(t),t)$ that I want to differentiate with respect to $t$. I know the command for partial derivative $\frac{\partial f}{\partial x}$,$\frac{\partial f}{\partial y}$,$\frac{\partial f}{\partial t}$, etc in Maple. But I can't find a way to find total derivative $\frac{df}{dt}$.
I know that NumPy has linalg.cond(A) to find the condition number of a matrix A. But, if I want to find the condition numbers of the roots of a large polynomial with respect to a small perturbation (something like Wilkinson's polynomial), is there a function that can give me the condition numbers of the roots directly?...
So I recently encountered this question in my head while taking my Scientific Computing class, where the lecturer talked about computing numerical error of a scheme. My guess would be that we take a much higher order scheme and treat its solution close to the analytical one and compute the error for the scheme we want ...
I'm trying to estimate DOA in the Hybrid architecture using root music so I need to solve the attached equation to find the roots for the Root_Music equation in Matlab. Does anyone have an idea for solving this? $$f_\theta(\theta)=g^H(\theta)\mathbf{a}^H_{M}(\theta)\mathbf{E}_{N}\mathbf{E}^H_{N}\mathbf{a}_{M}g^H(\theta...
Computer make it possible to find information in large databases. However, the results are often too large to be returned in their entirety to the user who requests them. Computer therefore sort the results by relevance according to their own metrics. They only display the first k results on a page. The user can then g...
The "standard" box-stacking algorithm(s) AFAIK assume a single stack and try to put the "largest" boxes on the bottom. The case I want to solve is simply to distribute the N boxes over (all) M stacks, such that the stacks are all approximately the same height (to the extent possible). The specific order of the boxes ...
I need to evaluate the hypergeometric function $_2F_1$ with $|z| > 1$ as in Wolfram Language with GSL but the GSL documentation says the $_2F_1$ needs $|z| < 1$. Is there any way I can use GSL and $_2F_1$ with $|z| > 1$? Any reference about the subject?
in our finite element class we were talking about interface problems our teacher came up with the following, where $K_i$ are two given functions and $u_i$ is the restriction of the solution $u$ to $\Omega_i$. $$-\nabla \cdot (K_i \nabla u_i) =f_i \text{ in } \Omega_i$$ $$u_i=0 \text{ on } \partial \Omega \cap \Omega_i...
For IEEE, the single representation is 1-bit sign, 8-bit exponent and 23-bit mantissa. This means that at each exponent value, you can test all 2^23-1 (roughly 9mil cases) possible combination of binary representation (give or take). Then you do it for all exponent value (255 values), and you can basically cover all fl...
Suppose I wish to solve a linear system $AX=B$ iteratively where $A$ is an $m\times m$ matrix and $X,B$ are $m \times s $ matrices (not single vectors). Instead of solving $s$ independent systems I'm exploring ways to solve them simultaneously so that matrix-vector products may better use caching (i.e. calculating $AX$...
I found in A Multigrid Tutorial: Second Edition by William L. Briggs‏, Van Emden Henson‏, Steve F. (here) the following Schemes: Two-Grid Correction Scheme, p. 37: And V-Cycle Scheme, p. 40 I want to check that I understood it correctly, Two-Grid is just a multigrid scheme when the algorithm going one level coarser. ...
Naive restriction operators in geometric multigrid that I have seen are typically implemented as a convolution and a subsequent averaging of every two entries in a vector $v^h$. For example: $$\tilde{v}^{h} = g*v^{h}, \quad v^{2h}_{1+i} = \frac{\tilde{v}^h_{2i+1}+\tilde{v}^h_{2i+2}}{2}, \, i\in\{0,\ldots,N/2-1\}$$ What...
How to position oneself, if one has little practical engineering background or function, but may have a broader insight into mathematical modeling? Or, lets say: I could write models to prove properties about the thing perhaps, but I wouldn't necessarily build that thing. And this is not the same as "writing some Mat...
Given n sets of points in general position in dimension 2 (n typically small, 2-6), can one find tuples of points, one from each of the sets, which are close in some sense (the closest, mutual distances less than some threshold)? I'd be interested even in the usual name for this problem.
I am trying to simulate solute transport of acid (HCl) and consequent mineral dissolution around a grain (calcite). The governing equation for transport is the advection-diffusion equation, given as: where C is the concentration, v is the flow velocity, D is the diffusion coefficient. At a constant flow velocity, the ...
Let $A\in \mathbb{R}^{n\times n}$ and $v \in \mathbb{R}^n$. We recognize $Av=\lambda v$ for some scalar $\lambda$ as an eigendecomposition problem. Suppose $\mu \in \mathbb{R}^n$, and let $\odot$ denotes the Hadamard product. Does this system $Av = \lambda v+ \mu \odot v$ correspond to any generalization of eigendecomp...
Suppose we have a linear algebra problem with a banded matrix A which has nonzero entries on the main diagonal, two nearest sub-diagonals, and two other sub-diagonals (such band structure often arises in the context of numerical solution of PDEs in 2D), $ A x = b $ and we write A as a sum of a 3-diagonal matrix $T_1$ (...
I have a problem which I believe is numerical instability when trying to solve a heat conduction equation using finite difference. The short version is that when the parameter $I=80.3$ I get the blue curve below (positive values and with one local maximum, which is physically reasonable), but when $I=80.4$ I get the or...
It was suggested on math.stackexchange.com that I try to ask this question here. Consider a bounded linear operator $A : U \to V$ where $U$ is finite dimensional and where $V$ is a separable Hilbert space, or with large dimension such that $A$ cannot be stored explicitly, being instead available as an algorithm for co...
I am trying to find the peaks. I have list x_period and y_power. I find the peaks from the y_power using peaks,_ = find_peaks(y_power,height=0). But, when I tried to plot plt.plot(x_period,y_power) plt.plot(peaks,ypower[peaks],'x') The peaks are not exactly on the peaks of the plot. The image is : How can I show the ...
I am using Immersed Boundary Method to simulate elastic particles in 3D Stokes flow. Specifically, one has $\nabla ^2 \mathbf{u}-\nabla p + \mathbf{f}(t) = 0$, $\nabla \cdot \mathbf{u} \; $, where $\mathbf{f} (t)$ is calculated based on instantaneous configuration of some particle assembly that is advected by flow $\ma...
I would like to ask a question on the implementation of finite volume method on a non-uniform grid in solving Navier-Stokeq equations. I will just post the screenshot of a PhD thesis, where I found the evaluation of the derivative term difficult to understand. The screenshot is below You can also see the non-uniform g...
I have a system of PDEs constituting an initial value problem (IVP) consisting of three coupled PDEs: \begin{align} \partial_t \rho + \partial_x(\rho v) &= \left(k_A (1-\phi) + k_B \phi \right)\rho\ \\ \partial_t \phi + v \partial_x{\phi} &= D \partial^2_x \phi + D \frac{\partial_x \rho \partial_x \phi}{\rho} ...
update: I've refactored the question based on helpful advice in the linked meta. I'm a heavy user of Python's NumPy and SciPy (and not much else) and for years I could run anything I need on my laptop. Now I will start to write simulations with 100's to 10,000's of elements that go way beyond what a single CPU can do i...
My current work requires using (Adaptive Mesh Refinement) AMR to resolve multi scale physics. I have a general question whether finite element is better than finite difference in this aspect or not. I know that finite element can solve equations on unstructured grid. Since AMR is nonuniform and can be structured or uns...
I would like to write a simple finite element solver in python in order to solve 2D Poisson equation and then visualize it. $$ -\nabla^{2} u(x,y)=f(x,y), \quad x,y \quad in \quad \Omega\\ u(x,y) = u_D (x,y), \quad x,y \quad in \quad \partial \Omega $$ Why do I wanna do that? I would like to learn how write a simple fi...
I have a set of points $P$ and want to find the ellipse with the smallest area that covers at least a fraction $f$ of these points. How can I do this? These questions ask the same thing, but folks have only provided approximate answers. This question asks for the smallest ellipse that bounds all the points ($f=1$). I d...
I simulated Oja's rule and BCM for a single postsynaptic neuron with two presynaptic neurons, and for 10000 inputs, where I randomly select one of $(0,1)$ or $(1/2,\sqrt{3}/2)$ as input. My learning rate was $1/100$ and I am using the sliding threshold for BCM. (I am following this tutorial: http://www.inf.ed.ac.uk/te...
I am trying to numerically evaluate the following Duhamel's integration: $$ x = \frac{-1}{\omega_d} \int_0^t \ddot{x}_g (\tau) e^{-\zeta \omega_n(t - \tau)} \sin{\left( \omega_d (t - \tau) \right)} d\tau $$ where $\omega_d$, $\zeta$ and $\omega_n$ are constants. From our data, $\ddot{x}_g(t_i)$ are given at each discre...
I have been trying to solve this equation and write the finite difference scheme in matlab for months, but I still am not successful. Given the KdV Equation $$\tag{1}u_{t} -6uu_x+u_{xxx}=0$$ I have come up with a semi-discrete centered difference finite difference scheme which has been checked and confirmed by my profe...
I'm having trouble with the following implementation of the KS model (see below) found on Solving numerically the 1D Kuramoto-Sivashinsky Equation using spectral methods When tN > 300 an overflow occurs on the line: u_hat2[:,j+1] = (1 / nx) * np.fft.fftshift(np.fft.fft(u[:,j+1]**2)) I tried using a workaround with the ...
I am solving a nonlinear least squares problem using Gauss Newton method. Due to the large dimension of the problem, I use the Hessian-free approach. As a linear solver I use either MINRES or CG. To speed up convergence, I began to figure out which preconditioners can be easily added. First, I decided to try the Fishe...
I have some matrix-valued, complex data $Z(f)$ with $f\in\{f_0,f_1,\dots\}$ and $Z(f_i)$ being a 3x3 matrix. I require the inverse $Z^{-1}(f)$ in my workflow. After encountering some problems with my results, I cold narrow the issue down to the inversion, which seems to be performed not very accurately by numpy.linalg....
Given a set of 2D points, I am trying to find the smallest convex hull that encloses an arbitrary point (which, in the general case, is not part of the set). By 'smallest convex hull' I am ideally thinking about its area, but I believe using the perimeter might also be good enough for my purposes. The problem specifica...
As a model of a more complex problem, I am studying a linear advection equation with a rapidly oscillating velocity $$ \partial_t u + a \cos(\omega t) \partial_x u = 0 $$ with initial condition $u(x,0) = \phi(x)$. The exact solution is $$ u(x,t) = \phi(x-a\omega^{-1}\sin(\omega t)). $$ I am trying to develop a finite d...
This is a re-posted question which was poorly defined earlier I have been trying to simulate reciprocating flow of a convective fluid through a heated channel in COMSOL-Multiphysics. The schematic of the domain is as follows: There is reciprocating flow of a convective fluid through the channel through the highlighted...
I have asked this in Mathematic section, but received no reply. Please let me ask here to see if threr is any difference. The Schrodinger equation without potential has the following form: $$\partial_t\psi =i\nabla^2\psi.$$ The finite element software that I'm using does not handle complex function directly, so I solve...
I think this is a question about the energy conservation of a numerical integrator. I'm studying the linearized 1D shallow water equations in python - for reference, here they are: $$ \frac{\partial u}{\partial t} +U\frac{\partial u}{\partial x}+g\frac{\partial h}{\partial x} = 0\\ \frac{\partial h}{\partial t} +U\frac...
For the 2-D Poisson equation $$-(u_{xx}+u_{yy}) = f \ \ \text{where} f = 1$$ For boundary conditions $$\frac{\partial u}{\partial n} = 0 \ \text{on AB and AD}$$ $$ u = 0 \ \ \ \text{on BC and CD no-slip condition}$$ I know how to solve this using both a Gauss Siedel and Jacobian method for normal problems however, what...
We were given an assignment where we had to determine the numerical solution of Dahlquist's equation $\dot x$ = $\lambda x$, ($\lambda$ = $-7$) for time steps ${0.5,0.25,0.125}$ using explicit euler method. When I coded it and plotted the solution on MATLAB, I saw that the solution unphysically oscillates for time step...
From what I read, the "default" go-to method for non-stiff ODEs is the Dormand-Prince Runge-Kutta pair; for instance, in Matlab docs, "Most of the time, ode45 should be the first solver you try". However, from what I understand multistep methods should be able to achieve comparable accuracies (same order of convergence...
Rosenthal's equation lets one calculate the temperature profile of a moving point heat source analytically for thin and thick plates. For simplicity I use the equation for thick plates defined as: $$T-T_0 = \frac{Q}{2\pi kR}\exp\bigg(-\frac{v(R+x)}{2a}\bigg)$$ Where $T$ is the temperature one wants to know, $T_0$ is th...
@Richard's answer to Going to try to move some of my scipy/numpy calculation to a new GPU, how to avoid disappointing results? is quite helpful, and as promised I've added a simple running example below of the kind of project I've started. While there may be "high level libraries" out there that can do this, I always c...
The mixed hybrid finite element method (MHFEM) is based on the mixed finite element method (MFEM). So, I'd recall the implementation of MFEM. The mixed formulation of Poisson equation reads $$\begin{equation}\begin{split}\mathbf{u}=\nabla h \text{ in } \Omega, \\ \nabla\cdot\mathbf{u}=0 \text{ in } \Omega, \\ \mathbf{u...
I'm trying to solve a Differential Algebraic Equation (DAE) in Julia which is very computationally expensive using GPUs. I'm brand new to Julia and don't have much experience coding with GPUs. The below problem is just a sample DAE problem I'm trying to solve. The error I'm getting, which occur on the last line of code...
When we do Hartree-Fock computations by solving the Roothaan equations $FC = SC \varepsilon$ is it a Galerkin method?
I need to solve a boundary value problem (BVP) of second order, where the equation depends on several know parameters, which are geometric parameters and material constants. I would like to solve this equation for several combinations of values of the known parameters. Is it possible to do this using solve_bvp()? I am ...
I want to numerically calculate OTOCs for different quantum mechanical systems. Consider the following Hamiltonian $$H=p_x^2+p_y^2+x^2y^2$$ and I want to calculate the following OTOC $$C_T(t)=-\left<[x(t),p_x(0)]^2\right>_\beta$$ where $$\left<\mathcal{O}\right>_\beta=Z^{-1}\text{Tr}(\mathcal{O} e^{-\beta H}),\qquad Z=...
I am trying to solve the 2D incompressible Navier-Stokes equations for laminar flow over a backward facing step using the finite volume method. This is the plot that I generated of a generic mesh showing u1, u2, and p nodes to help myself derive the discrete integrals in the conservation equations: The grid is stagger...
I cannot remember where I picked this up, but during my time reading about polynomial approximation for floating-point arithmetic of sin(x), I vaguely remember that there is an extra step in argument reduction. Specifically, it seems to involve "constructing a polynomial approximation for sin(x)/x instead", as "floatin...
While looking into the difference between staggered and collocated grids, I came across an effect called $2\Delta x$-oscillations, which happen on non-staggered grids, but not on staggered grids. This phenomenon is explained in an article by Stelling (1984) on pages 101-103, but I don't exactly follow the reasoning. Th...
In Bathe's Finite Element Procedures 2014 P346, the Jacobian is defined as follows: \begin{equation} \mathbf{J} = \begin{bmatrix} \frac{\partial x}{\partial r} & \frac{\partial y}{\partial r} \\ \frac{\partial x}{\partial s} & \frac{\partial y}{\partial s} \end{bmatrix} \end{equation} I need to calculate the following ...
I am aware of a symmetric matrix type in uBLAS as ublas::symmetric_matrix matrix. Is there an equivalent for this in Eigen library that can be used to construct one or do we need to explicitly check if a matrix is symmetric or not which could be a time expensive solution (O(n^2)). Any guidance is appreciated.
I'm looking for a simple, right-traveling wave for the linear shallow water equations (1D). My question: what are the initial conditions (velocity $U_0(x)$ and/or average water height, average velocity) for a simple (single!) right-traveling wave? I want to create a simple wave solution for the 1D shallow water equatio...
I have a grid of points $x_i$ and corresponding function values $y_i=f(x_i)$. I'm interesting in something like the cumulant of $f$, but it has an awkward prefactor. The desired quantity we'll call $$z(x) = e^{x}\int_{x}^{\infty}e^{-q}f(q)dq$$ And this quantity is needed for each grid point, $z_i=z(x_i)$ Let us assume ...
For solving linear problems stemming from PDEs with the FEM, such as the Poisson equation or the wave equation, it is customary to use the "simplest" numerical quadrature that exactly integrates the quantities that define the mass/stiffness matrices. More precisely, given shape functions $\phi_k$ for nodes $k$ on an el...
I have a set of coupled pdes which I want to solve using finite-difference, of which one is nonlinear. The three linear pdes for quantities $T_f$, $T_s$ and $c$ are convection-diffusion-reaction-like equations. The nonlinear equation for $\alpha$ is of the Arrhenius type: $\frac{\partial \alpha}{\partial t}=A_fexp\left...
This question is a continuation of one of my other questions. I've been trying to show that collocated (non-staggered) grids can suffer from negative group speeds in the linearized shallow water system. I do this by solving the equations for a simple, right-traveling wave crest, so that any left-traveling component can...
I was trying to install OpenFoam exactly as mentioned on their website. But when I run simpleFoam -help it says command not found, even after restarting my PC. I am using Ubuntu 20.04 lts. When I run tail ~/.bashrc, this is the output . "/home/hell/anaconda3/etc/profile.d/conda.sh" else export PATH=...
Note (2022/03/07): This question is solved. Unfortunately, I'm not able to accept the correct answer by Lutz Lehmann, because I screwed up my registration and the account which posted this question is different from the one I'm using now, even though they have the same name. I'm trying to find the eccentric anomaly of ...
When running my simulations I usually get result files with typical sizes of 10 GByte and larger. They contain vectors and matrices with data type float, double, complex float and complex double. Initially I used text files, but when storing the data for each simulation step in text files the amount of generated files ...
I want to implement incomplete Cholesky factorization to precondition, the algorithm I refer from incomplete Cholesky factorization, function a = ichol(a) n = size(a,1); for k=1:n a(k,k) = sqrt(a(k,k)); for i=(k+1):n if (a(i,k)!=0) a(i,k) = a(i,k)/a(k,k); ...
The strain energy of an incompressible Neo-Hookean solid is given as: $$ W = C_{10}(I_1 - 3) $$ Implying that at zero deformation $W = 0$, because $F = I \implies C = F^TF = I \implies I_1 = 3$ Strangely though, the second Piola-Kirchoff (2PK) stress is not zero $$ S_{ij} = 2 \frac{\partial W}{\partial I_1} \delta_{ij}...
Consider the following partial differential equation \begin{align} \frac{\partial u}{\partial t}+\frac{\partial f}{\partial x} &= g(x,t), \ \ x\in \Omega = [x_{L},x_{R}] \\ u(x,0) &= u_{0}(x) \\ u(x_{L},t) &= g_{1}(t) \end{align} where the flux function $f(u,x)$ is nonlinear. Let $\{x_{i}\}_{i=1}^{N+1}$ be a partitio...