instruction
stringlengths
43
28.1k
I'm want to load a mesh from a file, generated by triangle, and I want to use the boundary marks of its nodes (boundary marks of the file). It is possible? Also, I can change the mesh generator (or convert its output file), but I want to use the marks of the nodes of the file, is it possible?
I am new to Gmsh and I am having trouble creating a circle with a coarse mesh. I use Geometry->Elementary entities->Add->Circle to create the geometry and then Mesh->1D to create a mesh. Then I can can refine the mesh using Mesh->Refine by splitting but there seems to be no option for coarsening the mesh? For other s...
Let $M \in \mathbb{R}^{n \times n}$ and denote the set of Orthogonal matrices by \begin{equation} \mathcal{O}_{n} = \left\lbrace Q \in \mathbb{R}^{n \times n} \colon QQ^{T} = \mathbb{I}_{n} \right\rbrace . \end{equation} What is an efficient way to find the projection of an arbitrary matrix $M \in \mathbb{R}^{n \times...
Aim: I am trying to numerically solve a Lotka-Volterra ODE in R, using de sde.sim() function in the sde package. I would like to use the sde.sim() function in order to eventually transform this system into an SDE. So initially, I started with a simple ODE system (Lotka-Volterra model) without a noise term. The Lotka-V...
I need to solve a linear regression problem $$Ax=y$$ which is hugely underdetermined. I have around $10^6$ features but only $10^3$ equations. So $A$ is a $1,000\times 1,000,000$ matrix and $y$ a vector of length $1,000$, both are given and I need to find $x$ (of length $1,000,000$). The solution is of course $x^*=A^\...
I am trying to solve a system of 8 coupled differential equations using scipy's odeint. I have already written my code and it runs fine, but the solutions I get are completely different from what I expected. Originally, I would write all these equations within a loop, but since I was having problems with them I wrote t...
I was curious if someone could share their opinion on this matter. I have noticed that some people in literature normalize their Legendre polynomials, i.e. divide or multiply the polynomial by $$\sqrt{\frac{2n+1}{2}},$$ where $n$ is the order of the polynomial. I am quite new to DG, but I am experiencing better resul...
When doing LU decomposition, the algorithm will break down if any of the diagonal element $x_{ii}$ is zero. Therefore, we can use pivoting on the matrix such that $x_{ii}$ is no longer zero. That is instead of looking at the $x_{ii}$ we look at another element $x$ in the matrix. One problem with LU decomposition is th...
I'm working with Gmsh to generate 1D meshes of polygon edges. I have noticed that drawing a polygon by "vertices and lines" the program always assigns to the first N nodes of the mesh the coordinates of the N vertices of the polygon; all the other nodes instead are ordered clockwise. Is there a way to order all the no...
I have the following code which takes a DataFrame and plot the pdist matrix. from scipy.spatial.distance import squareform, pdist res = pdist(df, 'euclidean') df1 = pd.DataFrame(squareform(res), index=df.index, columns= df.index) plt.imshow(df1) I would like to reorder the columns such that the adjacency matrix will...
It seems that both piecewise-linear continuation and marching squares are methods to produce iso-contours of a scalar function given the function's values on a grid. It seems that piecwise-linear continuation works for any triangular mesh, not just a grid. Marching squares also has a variation which works on triangles...
In many quadrature problems, we are interested in computing $\int_a^b f(x) \, \mathrm{d}x$ via a quadrature sum. However, most software packages precompute the quadrature nodes and weights for use with integrals on $[-1,1]$ (Gaussian, Chebyshev and tanh-sinh quadratures are examples). Hence it is common to use a variab...
Let v_{0},...,v_{N-1} be N points in a Cartesian xy plane defining the vertices of closed polygon (i.e. v_{N} = v_{0}). Let P_{0} a point lying inside the polygon, point that is not known a priori. I am looking for a robust algorithm to sort the list v_{0},...,v_{N-1} clockwise/counterclockwise in respect of P_{0}. I ...
I am recently dealing with a diffusion simulation project and I have come up with the following code: N = 10000000 num_steps = 100 dim = 3 particles2 = npr.uniform(-1, 1, (N, num_steps, dim)) particles = np.cumsum(particles2, axis=1) To briefly explain: the first 3 lines are the simulation parameters; the number of p...
In Accuracy and Stability of Numerical Algorithms, equation 1.6a, Higham gives the following update formula for the mean: $$ M_{1} := x_1, \quad M_{k+1} := M_{k} + \frac{x_k - M_k}{k} $$ Ok, one benefit of this update is that it doesn't overflow, which is a potential problem when we naively compute $\sum_{i=1}^{k} x_k$...
I've been running various simulations with C++, and doing so has often involved saving lots of data to file (real/complex matrices, arrays, etc) and then reading them into other programs later. However, I have been unable to figure out a consistent and simple way of doing so. My solutions often involve several dozen li...
This is a particular case of a question I asked on Mathematics Stackexchange, question which got no answer so far. Let $n$ and $k$ be integers with $n\ge1$, $k\ge0$, and let $a(n,k)$ be the number of orbits of the symmetric group $S_n$ on the $k$-th iterated power set $$ P^k(\{1,\dots,n\}) $$ of the set $\{1,\dots,n\...
Hello I am in a basic numerical methods class and our teacher has given us an algorithm which can compute the inverse of a matrix other than using MATLAB's built in library function. A = [1 2 4; 1 3 9; 1 4 16]; b = [7; 13; 21]; [L, U, P] = lu(A); n = 3; X = zeros(n,n); for i=1:n e = zeros(n,1); e(i) = 1; X(:...
I'm looking for an open source software package that provides a fast evaluation of continuous Daubechies/Symmlet wavelet/scaling functions. GSL only has the discrete wavelets, and PyWavelets comes close to what I want, in that it gives a gives the values of the functions on an equispaced grid of whatever refinement you...
I'm looking for papers dealing with multi-objective non-linear programming which could help me implement an algorithm to solve my problem. My problem is : Maximize $f(x) = c \cdot x$, while minimizing $g(x) = r \cdot x$, where $\cdot$ is the scalar product. Constrained by $h_1(x) = \frac{v \cdot x}{p \cdot x} \geq 0.5$...
Problem Background I'm trying to find a solution/model to the following problem: Let's consider a cellular network (mobile network, ie., hexagonal cells) denoted $N$ composed of $|N|$ cells. Each cell $i \in N$ has a resources capacity $R_i$. Let $D_{i,j}$ denote the distance between the centers of two adjacent cells $...
Let $G(V,E)$ is a weighted simple graph, where $V$ and $E$ are the set of vertices and Edges. The graph is undirected. Let $A \in \{0,1\}^{n\times n}$ and $W \in R_+^{n\times n}$ be the adjacency matrix and the weight matrix of the graph. Note that both both $A$ and $W$ are symmetric. My target is to output a sparse re...
In the formulation of Euler-Bernoulli Beam Theory, there are two degrees of freedom at a point, $w$ and $\frac{dw}{dx}$. Typically, the finite element model of this theory uses cubic polynomial for interpolation of $w$ using a two noded element as given in Chapter 5 of this book. This element is a subparametric because...
I'm working on an inverse problem where the solution is the values of a 2D scalar field at the vertices of a 2D triangular mesh, such that the field can be defined continuously inside the mesh via barycentric interpolation. The problem is however quite sensitive to noise, and without any kind of regularisation to impos...
I have a linear system of equations $$Ax=b$$ where $A$ is an $N\times N$ matrix with integer values, and $b$ is a $N\times 1$ vector with integer values. Due to prior knowledge, I know that I am guaranteed that there exists exactly one rational solution $x$ such that $x=A^{-1}b$ (as well as that $A$ has full rank). ...
Given two solid bodies of masses $m_1$ and $m_2$ with invariable charge distributions $\rho_1(\mathbf{r_1})$ and $\rho_2(\mathbf{r_2})$ in them,* respectively, I would like to model the electrical interaction of the bodies using a user-specified electrical force law. * $\mathbf{r_1}$ and $\mathbf{r_2}$ are measured wit...
I have a smooth function $f(x) = \frac{g(x)}{h(x)}$ that is the ratio of two smooth convex functions $g(x)$ and $h(x)$. It is known that $f(x)$ has a global minimum, achieved at the unique point $x_0$. Also is known that $f(x)$ has countably many local minima, and function $f(x)$ value at no two local minima, is the sa...
I'm currently working with the following Poisson equation with mixed boundary conditions, including a Neumann boundary condition. $$\Delta u = f\\ u(x,0) = g_1(x), 0<x<1\\u(0,y) = g_2(y), 0<y<1\\ \partial_n u(x, 1-x) = 0, 0<x<1 $$ on the domain $\Omega := \{(x,y):\mathbb{R}^2_+:x+y<1\}$ As far as I understand, $\partia...
I'm refering here to Taflove's "computational electrodynamcis, 3rd ed." He says Let us assume that the structure being modeled extends to infinity in the z-direction with no change in the shape or position in its transverse cross section. If the incident wave is also uniform in the z-direction, then all partial ...
Given the 2D Poisson equation $$\Delta u = f\\ u(x,0) = g_1(x), 0<x<1\\u(0,y) = g_2(y), 0<y<1\\ \partial_n u (x, 1-x) =0, 0<x<1$$ defined on the domain $\Omega := \{(x,y) \in \mathbb{R}^2_+: x+y<1\}$, discretize the equation using Shortley-Weller approximation with 5-point stencils. On this domain, however, it appears ...
This is a problem from projective geometry. Suppose I have a vector $z \in R^k$ of unit length $\| z \| =1$ inside a $k$-dimensional hypercube. I don't know its value but do know its projection upto an unknown face-dependent scaling factor $\lambda_j$ onto $(k-1)$ orthogonal faces, $j = 1 \ldots (k-1)$ of the cube. My ...
Do there exist "frameworks" as to how computational scientific experiments claim validity? Like "scientific method for computed science"?
$F$ is $m\times m$ diagonal, with real non negative elements $D$ is $n \times m$ complex $P$ is $n \times 1$ complex $A$ is $m \times 1$ complex. Minimize $\Gamma(A)$, with respect to $A$. $$\Gamma(A) = \frac{m^2(DA-P)^H (DA-P) + (FA)^H(FA)}{A^HA}$$ It is known that both numerator and denominator of $\Gamma(A)$ are con...
Let $M$ be a $m \times n$ matrix, $x$ a $n$-vector, $y$ a $m$-vector, and $\|\cdot\|_2$ represent the $L_2$ norm (i.e., Euclidean norm). Given $M,y$, the goal is to find $x$ that minimizes the expression $$\Psi(x) = \|x\|^2 + \|Mx-y\|^2.$$ Is there a closed-form expression for the optimal $x$? Without the $\|x\|^2$ t...
I wanted to solve a periodic elliptic equation of the form $$-\nabla\cdot(A\nabla u)=-\nabla\cdot F$$ on $Y=[0,2\pi)^d$ using FreeFem++, where $A$ and $F$ are $Y$-periodic. The space of solutions is $H^1_{per}(Y)/\mathbb{R}$, which can also be seen as the space of periodic $H^1$ functions with zero mean. How does one t...
I'm having serious troubles with solving translating 3 coupled differential equations into python. The 3 DE's stem from a 4th order DE used to calculate the bending moment of an underwater pipeline that has been substituted/transformed into 1st order equations and are coupled to each other. 4th order: $\frac{d^4 w(x)}...
I am using an Adam Bashforth 4 method to solve an IVP problem so I need other numerical method to estimate the first 3 values. I am very much interested in finding a way to estimate the first 3 values and that particular method should have order of accuracy of 4. Which method would you suggest? From a theoretical point...
Let us consider a problem of the form $$(\mathcal{L} + k^2) u(\mathbf{x})=0\, ,\quad \forall \mathbf{x} \in \Omega$$ with Dirichlet boundary conditions $$u(\mathbf{x}) = 0, \quad \forall \mathbf{x} \in \partial\Omega\, .$$ We discretize this problem using, for example, the finite element method, to obtain the following...
Assume one uses the classical AMG with Ruge-Stuben coarsening and direct interpolation for solving real valued problems. How can this approach be recycled to also solve complex valued problems like every harmonic simulation? I have read in papers that it is possible to split the real and imaginary part and create an eq...
I'm interested in a good reference/paper about how to handle numerically a mass-matrix system as \begin{align} \mathbf{M}(t,y)\dot{y} =F(y,t) \end{align} I know that such a problem can be solved by using classical ODEsolvers in MatLab such as ode15s, and others. Of course, due to copiright issues, it's not possible to...
I have series of points extracted from a regular grid, with their X/Y coordinates. A previous algorithm (that I cannot modified!) output a list of these coordinates, but the ordering of these point is random in regard to the scope of this problem as expressed byt the following python-style notation: [ [X_O,Y_O], [X_M, ...
Have Schoenberg's cardinal B-splines been extended to accept derivative information at each knot, similar to how Lagrange interpolation can be improved by Hermite interpolation?
I have been working on a hybrid dimensional model using the mixed FEM formulation, in which 3D elements and 2D elements are combined by certain relationships between the degrees of freedom (DOFs) between face flux for 3D elements and pressure DOFs for 2D elements. I'm doing this for Raviart Thomas elements of various o...
Are there efficient public solvers for the time-dependent Schrödinger equation with time-independent Hamiltonian and 2 or 3 degrees of freedom?
Can anyone recommend a structural analysis library that satisfies the following requirements: C++ API Simulate both beam elements and shell (slab) elements Both static and dynamic analysis Free and/or open-source We're essentially looking to find a library that can do analysis similar to e.g. SAP2000. However we are ...
I am working on an interesting algorithm: Its absolute error is exponential in a parameter $j \in \mathbb{N}$, and for a given $j$, I have complete freedom to choose between an $\mathcal{O}(1)$ time-complexity algorithm with memory consumption ${\sim}2^{j}$, or a $\mathcal{O}(2^j)$ time-complexity algorithm with $\math...
I am very interested in optimizing the hell out of linear system solving for small matrices (10x10), sometimes called tiny matrices. Is there a ready solution for this? The matrix can be assumed nonsingular. This solver is to be executed in excess of 1 000 000 times in microseconds on an Intel CPU. I am talking to the ...
Context: For a fluid solver, I need to compute areas and volumes of curved elements. My curved elements are quadratic triangles and quadratic tetrahedra, defined by their Lagrange nodes. Question: Consider a 3d quadratic $\mathbb{P}_2$ tetrahedron defined by the positions of its 10 Lagrange nodes. Its volume is the i...
I am trying to solve a 2D elliptic PDE (see complete electrode model for electrical impedance tomography) using the finite element method (FEM) over a circular region $\Omega$. I have discretized the model, and got the following surface integral $$\int_e \phi_i(x,y) \phi_j(x,y) \mathrm{d}s, \mbox{ for } i,j = 1,...,n\,...
I am a little bit confused over the concept of translational and rotational degrees of freedom (DoFs) in structures, and their relation to displacement/traction BCs. Do displacement boundary conditions constrain translational DoFs, only, or also rotational DoFs? For example, for a 3-D case, if I specify the 3 translat...
Problem. Consider the one-dimensional adjoint Euler equations for $(x,t) \in \Omega \times [0,T]$ with $\Omega \subset \mathbb{R}$ and $T > 0$ $$ \varphi_t + \Big(\frac{\mathrm{d}F}{\mathrm{d} U}(x)\Big)^{\top}\ \varphi_x = 0 \quad \text{in} \quad \Omega \times [0,T] \tag{$*$} \label{eq:adj}$$ where $F$ is the flux vec...
I have what would be a straightforward mixed-integer linear programming problem, except for the fact that some of the constraints are of the form $f(x_1,x_2,x_3,\ldots,x_n) < c$, where $f$ is 'take the maximum of the largest coordinate and the sum of all the smaller ones' In lisp: (defn f [& l] (let [sl (reverse (sor...
Most CFD codes use FVM. Most computational structures codes use FEM. Why is the FEM not frequently used in CFD, and why is FVM not frequently used in FEM?
When solving systems of non-linear equations using Newton's method, it is often observed that the system has an independent sub-system, e.g. : $$ f(x,y) = 0 $$ $$ g(x,y) = 0 $$ $$ h(x,y,z) = 0 $$ If I am not mistaken, you can (and should) solve first for $x$ and $y$ and then subsequently solve for $z$. Now when the dim...
I have implemented an Adams Bashforth 4 method to solve an Initial Value Problem for an ODE and I am testing it against the test equation: $y'=\lambda y$ with $y(0)=1$ with the exact solution: $y(t)=e^{\lambda t}$. I have set $\lambda =1$. I get decent results and decent rate of convergence because the loglog plot is l...
In the realm of scientific computing, there are a plethora of techniques developed to solve Partial Differential Equations (PDEs). Many of the popular methods are variants of common techniques such as Finite Differences, Finite Volume, Finite Elements and the theory behind where they work or not is pretty extensive. Ea...
For a little personal project, I am picking up my FEM skills again. I learned a lot about the theory back in university and I am able to implement a simple FEM solver for specific problems but I was curious about the different parallelization possibilities because we never went into those too deeply. Let us focus on t...
I have a large system of homogenous inequalities involving 33 real unknowns of the form $$ \vec{F}(z_i)^T \cdot \vec{X}>0\, $$ where $\vec{X} = \left(x_1,...,x_{24}\right)^T$ are the unknowns and $\vec{F}(z_i)$ are functions depending on a real parameter $|z_i|<1$ which parametrises the system, that is to each value of...
I would like to get the power from a Gaussian beam given a set of points at which electric field is evaluated. Please follow my reasoning and tell me what assumption maybe are wrong Power definition is: $ P = \int |E|^2dA$ We integrate over area, then Power is a quantity that does not depend on the geometry. If we com...
I have a simple but long function that takes a vector x[10], and outputs a vector y[100]. It is an automatically generated eval function for a multivariate polynomial, ie, there is only (complex) multiplications and additions involved (5000 of them), with many variables to cache intermediate results that are reused. Th...
I'm trying to simulate the scattering of a wave-packet at a potential barrier in Python. I'm using a Fourier Transform method (not sure if its the same as the Split-Step method), where I apply Fourier Transform on my initial wavepacket (plane wave in a gaussian envelope) to get the wavefunction in momentum-space: $$\ph...
I am trying to implement a simple logistic regression algorithm from scratch in python (for learning purposes). Every article I've seen online so far presents the following expression for $z$ (argument of the sigmoid function): $$z = \theta^T\cdot x$$ However when they implement it in code they always use np.dot(X, the...
I am trying to simulate multiple harmonic oscillators in periodic boundary conditions (subsequently visualizing the process in VMD). I have successfully simulated multiple HOs by using the Leapfrog algorithm, but when I try to impose the periodic boundary conditions on the simulations, unexplainable things start to hap...
I am following a course of computational material physics. The professor uses fortran to code and uses lapack to solve eigenvalue problems. So far I just know c++. There is an equivalent library that make the same as LAPACK but in c++? Which is the best one ? Should I prefer to use fortran rather than c++ for my scope?...
I am solving an advection-diffusion equation using the FEM and am having trouble calculating my fluxes. I start with the equation, $$\frac{\partial n}{\partial t} = \frac{\partial j_{n}}{\partial x}\, ,$$ Where my flux (current density) is given by, $$j_n = \mu E n + D \frac{\partial n}{\partial x}\, ,$$ where $\mu$ i...
Given a linear system $A\textbf{x}=\textbf{b}$, we can express it into the easier-to-solve right-preconditioned form: $$ AM^{-1}\textbf{y}=\textbf{b}, \quad \textbf{y}= M\textbf{x} $$ On the other hand, the left-preconditioned system is: $$ M^{-1}A\textbf{x}=M^{-1}\textbf{b} $$ From the literature we know it's easy to ...
EDIT: I moved the full code to my github page so the post can be read more easily. I am writing a script to take the Faber approximation approach outlined in Hassan Fahs paper (free access) and apply it to the Liouville-von-Neumann equation to propagate the density matrix $\rho$ with some inspiration from the scripts f...
Richardson's iteration introduce a scalar $\alpha$ to the update formula: $$ \textbf{x}^{(k+1)} = \textbf{x}^{(k)} + \alpha \textbf{r}^{(k)} $$ And compute $\alpha$ by minimizing the spectral radius: $$ \min_{\omega}\,\rho(B) = \min_{\omega}\, \rho(I-\omega A)\, . $$ As $I$, and $A$ do not change over the iterations, i...
Modern augmented reality platforms such as Google's ARCore and Apple's ARKit seem to only operate on mobile devices, I'm guessing, because their underlying algorithms require specialized hardware that is typically available on these devices (accelerometers, gyroscopes, etc.). Since this hardware isn't available on lapt...
Is it possible to view the data stored in the various PETSc data types from within totalview? Ordinarily, PETSc types are integers which act as pointers to the actual data (obviously my understanding of this is quite weak). So when debugging and troubleshooting, my workflow looks like 1) Edit the source to save the PET...
I am reading Professor Saad's "Iterative Methods for Sparse Linear Systems" (2nd edition). The basic algorithm for FOM is given on page 166 and the basic algorithm for GMRES is given on page 172. Both FOM and GMRES appear to build the same Krylov subspace and upper Hessenberg matrix. However, at the very end of the a...
I'm curious to know how QUADPACK's QAG routine works. My understanding is that it begins by calculating on each subinterval the numerical quadrature with a Gaussian-Legendre rule and a nested Kronrod rule to provide estimates of the integral and the local error. Then, globally the interval with the highest error is b...
In classical linear elasticity, when modeling a force/load boundary condition, it appears that we could either: Use a pure Neumann boundary condition, where the 3 traction components are specified. In 3-D the 2 tangential traction components would be zero, with the non-zero component being the normal component. Use a ...
I am working through an exercise in my textbook and implementing the code in Python to practice dynamic programming. I feel like I am right on the edge of figuring it out, but after many hours, I come here for help. Basically, my code is going through a list of values x, and given a k, breaks that list into k clusters...
What are the most sophisticated methods for interpolating a scalar field say Electric or Magnetic Field on a 3-D grid? I have scalar data on a meshgrid with equal spacing. I would like to use an interpolating method to interpolate those values onto random points I select on the same grid. I think my best bet is using ...
Suppose we have a conformal mapping from the unit disk in the $\omega$ plane onto the exterior of a polygon in the $z$ plane. The Schwarz-Christoffel mapping in this case is defined as: $$f(u) = A - C \int^u w^{-2}\prod_{k=1}^{n} (1-\frac{\omega}{u_k})^{1-\alpha_k} d\omega.$$ Meaning that we determine the vertex $z_k$...
I want to discretize the following equation using a Finite Volume Method $$\nabla \cdot (a(x)\nabla u)=f(x)\\x\in \Omega \subset \mathbb{R}^2 \\u_{|\partial\Omega}=g$$ I'm using Voronoi cells here: let $V_i \subset\Omega$, $i=1,\dots,N$, such that $\bigcup\limits_{i=1}^N V_i=\Omega$, $V_i\cap V_j=\partial V_i \cap \par...
I have a diffusion problem which can be broken down to be: $-\Delta u = f(u) $ on $\Omega ~/~ \Omega_{int}$ $u = 1$ on $\Omega_{int}$ Note that this is an internal Dirichlet constraint to the value 1.0 in the center circle, unlike the standard textbook examples with homogeneous boundary conditions. (see picture) Th...
I'm working with a finite element model in which I'm interested to minimize the average temperature at a surface. I have 15 independent variables in my model, including geometry, materials, flows, process times, etc. Most of my variables are continuous but some are discrete; and it takes me ~10 mins to run one simulati...
I'm discretizing the following Poisson equation using FVM where the domain $\Omega$ of the solution is a regular hexagon of side $1$ centered about the origin. $$\Delta u =k,\text{ $k$ constant}\\ \partial_n u = 0\\ \Omega \subset \mathbb{R^2}$$ I'm not really quite sure if my discretization and especially the argument...
I am searching for an optimization solution, which is a 8d vector representing 4 complex elements, where each element is within the complex circle with maximal radius 1.2. The objective function is: $$f: \left\|\mathbf{c}_{ref}-\mathbf{c}\right\|_{2}+\left|2-\|\mathbf{c}\|_{2}\right|$$ I am using the scipy.optimize.bas...
I'm trying to improve the speed of the following iteration to calculate $s_k$: $$B_k^{-1} = \Bigg( I + \frac{s_{k}s_{k-1}^T}{||s_{k-1}||^2}\Bigg)...\Bigg(I+ \frac{s_1s_0^T}{||s_0||^2}\Bigg) B_0^{-1}\\s_{k+1} = -\frac{B_k^{-1}r_{k+1}}{1+\frac{s_k^TB_k^{-1}r_{k+1}}{||s_k||^2}}$$ If we calculate $B_k^{-1}$ explicitly then...
We have the following generalized eigenvalue (set of) problem(s) $$[K_R(\kappa)]\{u_R\} = \omega^2[M_R(\kappa)]\{u_R\}\quad \forall \kappa \in [\kappa_0, \kappa_1]$$ with \begin{align} &K_R(\kappa) = T^H(\kappa) K T(\kappa)\, ,\\ &M_R(\kappa) = T^H(\kappa) M T(\kappa)\, ,\\ &u = T(\kappa) u_R\, . \end{align} Where $K$ ...
Given a large matrix $A$ with eigenvalues $\sigma_1\ge \sigma_2 \ge \dotsc $, I want to determine only a subset of these values, say $\sigma_5,\sigma_8$ and $\sigma_{19}$. Is there an algorithm that can do this, or is finding the top 19 eigenvalues the best that can be done?
I have a linear system of the type $$Ax = b$$ I want to minimise $|b - Ax|^2$. I know there are different approaches to directly solve the system (Normal equation + Cholesky, QR decomposition, SVD decomposition) that have different numerical stability. I would like to ask how it is possible to estimate the impact of th...
I am trying to write on paper the piecewise polynomials given by the splinefit function, but I am having some problems figuring out what the coefficients should be. So, the output from the script gives me the following: scalar structure containing the fields: form = pp breaks = Columns 1 through 15: -1.00000 -...
I would like to solve the following differential equation numerically in 2D, $$\frac{\partial z^-}{\partial t}+(\vec{B}\cdot\vec{\nabla})z^-=0,$$ see Wikipedia if you are curious about what the symbols mean, where $$\vec{B}=(B_x,B_y,0).$$ I have attached some code which can solve this to first order accuracy in python ...
I have read a lot about numerical integrators (ode solvers) lately and tried reading a few papers but I have stumbled upon something that I can't understand and it's something called ABA and BAB. For example in this paper New families of symplectic splitting methods for numerical integration in dynamical astronomy the...
I'm trying to read papers on numerical ODE algorithms and I always seem to stumble upon huge amounts of exponentials multiplied by each other. For example in New families of symplectic splitting methods for numerical integration in dynamical astronomy there are a few of them. Is it the ordinary exponential that is mean...
I have noticed arpack comes with a driver dsdrv1 that exploits symmetry of a real-valued matrix. Is there a way to analogously exploit a Hermitian matrix in some way via z--- drivers? The manual discusses Hermitian matrices in section 3.2.1, but I'm not sure if this analysis and proposal is already present in the ARPAC...
An optimization problem has 3 main components: decision variables, constraints, and an objective function. Such a problem can be mathematically modelled and solved using an optimization solver. For example, a SUDOKU puzzle can be modelled as such and solved using a solver. What are examples of famous real-life problems...
When solving a system of ODEs, as part of a preconditioner, I get the system $(A + D(t))x = b(t)$ where $A$ is a sparse matrix and $D(t)$ is diagonal. I'm currently solving this by taking the LU-decomposition of the system for each $t$. $A$ is constant throughout the solution. Is there an algorithm that would allow me ...
I am writing some simple code to raise a base value to a power then perform some operations on the output. I have included the code I am using now, below ( see end of this message ), also see immediately below what this looks like when I run my script from the console ; C:\PYTHON34>python tst.py INPUT Value: 431.1 INP...
I am using ARPACK's zndrv1 to diagonalise a matrix (the context is quantum chemistry). While all vectors have a norm 1, as expected, vectors corresponding to degenerate eigenstates aren't always orthogonal (often their inner product will be roughly 0.01). Are there any parameters I can adjust to improve orthonormality ...
The equation is $$\frac{\partial}{\partial x}\left(u\frac{\partial u}{\partial x}\right)=f(x)\\ 0<x<1, u(0)=u(1)=0$$ I'm discretizing this PDE using FVM as follows: $0=x_0=x_{1/2}<x_1<x_{3/2}<\dots<x_{N+1/2}=x_{N+1}=1$ $h_i:=x_{i+1/2}-x_{i-1/2}$ $h_{i+1/2}:=x_{i+1}-x_i$ $$\int\limits_{x_{i-1/2}}^{x_{i+1/2}} \frac{\part...
Consider a Boundary Value Problem: $$ \delta u''+u(u'-1) =0 \Leftrightarrow u''=\frac{-u(u'-1)}{\delta}=:f(t,u',u), \\ u(0)=a, u(1)=b $$ $\delta,a,b$ are known parameters. I want to implement Newton's method on a uniform grid. How do I derive the Jacobian?
I developed the code below for performing gaussian elimination in order to evaluate the determinant of a matrix: program det3 REAL, DIMENSION(3,3) :: matriz = RESHAPE([1,2,3,-7,13,5,4,-21,8],[3,3]) REAL :: temp, m INTEGER :: n = 3 INTEGER :: i, j, k INTEGER :: fator_cor = 1 REAL :: det DO k=1, n-1 DO i = k+1, n...
I am recently starting with OpenFoam. I have a Mac as my personal laptop, but I would have to use OpenFoam on linux in my lab. So my questions are: 1) Is the OpenFoam software independent of OS, so that I can use interchangeably on both Mac and linux. 2)I am fairly good with C programming(I am not really comfortable wi...
I want to discretize the following parabolic PDE: $$u_t = \nabla\cdot(\alpha(x)\nabla u)- \beta u\\ x\in\Omega \subset \mathbb{R}^2\\ \partial_n u = 0\\ u(t,0) = u_0(x)\ge 0, \alpha(x)>0$$ Given the Neumann boundary condition above, one can integrate this PDE: \begin{alignat}{2} \frac{\mathrm d}{\mathrm dt}\int_\Omega ...
I am writing some functions to interpolate data. While using interp2D, somehow, a sample matrix works but when I change the size of the matrix, it returns an error. #!/usr/bin/python3 # # Useful interpolation functions in python. # import numpy as np import scipy.interpolate def interp_2d(x,y,fxy,x_desired,y_desir...