instruction
stringlengths
43
28.1k
I am studying the discretization of Poisson's equation in $1D$. In Matlab I created different discretization matrices (Laplace operator) according to different sizes of the mesh: % Parameters N = [40, 80, 160, 1280]; % Dimension 1-D grid % Laplace operators L1 = -1/((1/N(1))^2) * full( ( spdiags(repmat([1,-2,1], N(1)-...
Given a set of points $\{x_j\}_{j=1}^n$ in $[-1, 1]$, I would like to compute $$ \int_{-1}^{1} L_i(x)\,\text{d} x $$ exactly. $L_i$ is the Lagrange polynomial with respect to the points $x_j$ with $x_i$ as node, i.e., $$ L_i(x) = \prod_{j\neq i} \frac{x - x_j}{x_i - x_j}. $$ Since this is a polynomial of degree $n$, I ...
I'm currently developing a program to solve 2D transient state heat conduction on a square plate using the V-cycle multigrid. Althought my program is able to reach the steady state solution, it's computational time is longer then just running the problem using Gauss-seidel method. Problem case: 0.1 m by 0.1 m square pl...
I am aware about that inverting a matrix to solve a linear system is not a good idea, since it is not as accurate and as efficient as directly solving the system or using LU, Cholesky or QR decomposition. However, I have not been able to check this with a practical example. I have tried this code (in MATLAB) M = 500;...
If we take a 1st order polynomial approximation in each cell, we can find the (2x2) -mass matrix, differentiation matrix, and flux matrix through the integration of Lagrange polynomials. However, I am not able to comprehend the simplified equation which we obtain on using centered numerical flux. It seems that we get ...
I'm using a simple version of Verlet integration for a particle–particle interaction system with collisions. At the end of each iteration, I integrate like this: verletX = ( 1.92*x[i] - 0.92*x_old[i] ) + fx[i]*0.002; verletY = ( 1.92*y[i] - 0.92*y_old[i] ) + fy[i]*0.002; x_old[i] = x[i]; y_old[i] = y[i]; x[i] = verletX...
I am looking to learn Fortran for Scientific Computing, which IDE setup for this exists that supports debugging, code completion capabilities and offers granular Running time Analytics. I am interested in a free software that accomplishes the above requirements and is available on Mac.
My goal is to numerically solve the convection-diffusion equation of the form: $$\frac{\partial C}{\partial t} = \nabla (D \nabla C) - \nabla (v C)$$ $C$ is concentration and $D$ is the diffusivity constant. I am simulating this on a small flat plate model of porous media. I am assuming that fluid flow goes across the...
An element $a \in \mathbb{Z}_n$ is a quadratic residue in $\mathbb{Z}_n$ if it's congruent to some perfect square modulo $n$. Is there an efficient algorithm to find all quadratic residues in $\mathbb{Z}_n$? $n$ is composite and we know all it's factors if that helps. Update: We have one more restriction: $n$ = $p_1 p_...
I would like to create a parallel solver using petsc4py as one component of a larger application. I can easily get PETSc.COMM_WORLD.getSize() to be 4 by calling mpiexec -n 4 python my_prog.py however, this creates 4 applications, whereas I only want the PETSc solve in parallel. Currently it is only using one process, ...
I have good background of finite element methods and continuum mechanics and I am familiar with fluid mechanics. My aim is to understand the required theory and to write my own simple codes using finite element, finite volume or other methods. I am looking for references for computational fluid dynamics. I am beginner ...
I would like to use MKL to solve a sparse linear system. I chose the DSS (Direct Sparse Solver) interface, which implements the following steps: //(1).define the non-zero structure of the matrix dss_define_structure(handle, sym, rowIndex, nRows, nCols, columns, nNonZeros); //(2).reorder the matrix dss_reorder(handle, o...
I had to code a program which calculates Inverse of a matrix by Gauss-Jordan Inverse method , I was trying to analyse the program and then code it myself. the link http://hullooo.blogspot.in/2011/02/matrix-inversion-by-gauss-jordan.html I understand it all except two things - 1) I don't understand how it does the row ...
I have to solve a system $Ax^{(n)} = b^{(n)}$ many times, $A$ being a sparse (pentadiagonal in most part of its structure), unsymmetric, constant matrix. Currently, I am performing the LU factorization with rows and columns permutations, i.e., $PAQ = LU$, and then I am using this factorization to compute $x^{(k)}$ in t...
The Lenstra–Lenstra–Lovász (LLL) algorithm is a famous one for lattice reduction. But concerning its application, I am always baffled by one point. The algorithm applies equally well to irrational and rational numbers, right? But, it seems that in the literature, people always confine themselves to the rational case. ...
Suppose we have a straight line in Cartesian space such that $$ x_k = x_0 + k \delta x, \quad \quad y_k = y_0 + k \delta y, \quad \quad z_k = z_0 + k \delta z $$ where $k$ can take any real value. If we project that line into cylindrical polar coords then $$ R_k = \sqrt{ x_{k}^{2} + y_{k}^{2} }. $$ Now suppose there ex...
Given a polyhedron $\mathbf{Ax} \leq \mathbf{b}$, how to find the largest hypercuboid, with unknown center $\mathbf{x_{0}}$ and side lengths $2\epsilon_{i}$, which are aligned along the co-ordinate axes that fit inside? By 'largest', I'm flexible with the definition. It could be $\prod_{i} \epsilon_{i}$ or $\sum_{i} \e...
What is a simple way to compute $10^x - 1$, where $x$ is close to zero? Using exponentiation and then subtraction isn't good enough, because the fractional part is very small compared to the one that we subtract away.
For a flow simulation I am trying to reproduce a specific screw element design for an intermeshing co-rotating twin-screw extruder. I am using gmsh (v2.16) where the element is made from a 2D surface with a combined translational and rotational extrude command. The 2D sufrace is a simple shape as seen on the left in th...
I've asked this question on Computational Science SE too. Consider the following triangulation of a rectangle $(0,a)\times(0,b)$: We have two types of triangles: I enumerate the rectangles(consisting of two triangles) starting at the bottom left corner from left to right and bottom to top. The triangles are enumera...
I submit a Reduce command and get results like this: Reduce[t0 >= 0 && -9 + t0 - 5 t1 + 154 >= 0 && -5 + t0 - 3 t1 + 77 >= 0, {t0, t1}, integers] With output: Reduce::bdomv: Warning: integers is not a valid domain specification. Assuming it is a variable to eliminate. (0 <= t0 <= 75/2 && t1 <= (72 + t0)/3) || (t0 ...
I'm dealing a lot with large sparse linear operators these days and I'm quite new to them. A lot of the matrices I deal with originate with only a few unique integers, however, there are lots of them. As a result I have tons of memory locked up for the same values and fetching them from RAM seems like quite the bottle ...
I'm trying to do discretization to the following system: $\frac{{\partial \rho }}{{\partial t}} = - \frac{{\partial \rho }}{{\partial x}}u - \rho \frac{{\partial u}}{{\partial x}}$ $\frac{{\partial u}}{{\partial t}} = - u\frac{{\partial u}}{{\partial x}} - \frac{\partial }{{\partial x}}\left[- {\frac{1}{{\sqrt \rho ...
So the problem I am working on is as such. Given the x,y,z data of a periodic object over time (from the origin in 3d space) (need not be uniform), calculate the period of the object (if the data given is periodic and the calculation is possible). So the best idea I have been able to come up with so far, is to use some...
exchangers, I have run into a bit of a puzzling problem. To solve an complex eigenvalue-problem, I make use of the LAPACK library function ZHEEV. To test the implementation I used a real symmetric matrix: \begin{align*} \left[ \begin{array}{c c c c} 2 & 0 & 2 & 0 \\ 0 & 2 & 0 & 2 \\ 2 & 0 & 2 & 0 \\ 0 & 2...
I am trying to implement the Laplacian operator using Fourier Transform differentiation (https://en.wikibooks.org/wiki/Parallel_Spectral_Numerical_Methods/Finding_Derivatives_using_Fourier_Spectral_Methods#Taking_a_Derivative_in_Fourier_Space). I am comparing my Fourier differentiation with a periodic Laplacian in real...
I was thinking about the following problem: Suppose there is a positive semidefinite matrix $X$ of size $n$ (for example, a kernel). Suppose $X$ can be approximated as a low rank matrix, $X\approx GG^T$. Is there a way to find the $k$-largest/smallest values of each row of $X$ without computing it explicitly and going...
So I have been working on a Smooth Particle Hydrodynamics (SPH) simulation and I am trying to implement the Marching Cubes (MC) algorithm to visualize my SPH output. I understand the MC algorithm well enough from reading about it, however usually it is discussed assuming that you already have some scalar field which yo...
Consider this basic scheme for particle in cell simulations ( with just short-range interactions ): assign particles to disjunct cells for cell $A$ go over neighboring cells $B$ for each particle $a_i$ in $A$ interact with all $b_i$ in $B$ move all particles For GPU is very important memory locality. Therefore it...
The Rhie--Chow [1] interpolation seems to be a standard tool in the Finite-Volume discretization of incompressible flows. It is commonly defined on the discrete level [2]. In the lecture notes [3] -- Chapter 6, page 56 [2] -- it says that We find that the Rhie-Chow interpolation is the same as adding a pressure term...
I was reading about the Crank-Nicolson method, and it is often said that it can produce "spurious oscillations" or that this method is prone to "ringing", especially for large time step and stiff initial value. I'm curious about that phenomena but I can't find any satisfying answer. I read on this website that this cou...
For geotechnical engineering problems, it is common to fix a single component of displacement along a boundary as a Dirichlet boundary condition (roller boundary condition). However, I'm having trouble seeing why this leads to a well-posed problem. The number of unknowns in an elastic problem is equal to the dimension...
I'm trying find the eigenvalues of a matrix A using QR iteration with Householder. I used this code which I found from Cornell University that decomposes QR with Householder. A= [3.56829648331616, -2.19026841424281,0.557474633283884,-0.126072015319561; -3.25393787896303, 4.81285873937612,-2.79568990543933,0.63224...
If $I_h$ is the bilinear interpolation operator, i.e. $I_h: H^2(\Omega)\rightarrow V_h$, where $V_h=\{v_h\in L^2(\Omega)|v_h|_K\in \mathrm{span}\{1,x,y,xy\},~~K \in\mathcal{T}_h\}$ i know that $\|I_hu\|_{0,\infty}\leq C(u)$ for $u\in H^2(\Omega)$. However, i dont know how to prove it. Can any one give me some suggestio...
I'm studying the Fisker-KPP equation on the line (and in $]0, 100[$ numerically): $$ \partial_t u = \Delta_{xx} u + u(1-u) $$ I notice a behavior I don't understand with a smooth initial condition $u_0$ that has the following form: $$ u_0(x) = \left\{ \begin{aligned} &1 \quad \mbox{if} \quad |x-50| < 10 \\ &\exp{\left(...
I have a $9 \times 9$ square lattice. In each site of the lattice, there are $N$ molecules, where $N$ is a large random number and it is different for different sites. N equal to 100000000+-100 in beginning and changes by passing time. I want each molecule to do a random walk in each time step. $N$ is very large and it...
Some context: I am working with the Black-Scholes model.. I have an explicit (Black-Scholes) formula which is the exact solution to my problem. I have written code which implements a finite-difference scheme (explicit Forward-Euler, i.e: forward march-in-time iterative scheme) to approximate the solution to a partial d...
Maybe my question is obvious but i cannot find any good source which answers it I trying to learn about proximal gradient. One thing which is not clear for me is particular algorithm for line search. According to this presentation (slide 20) and some other sources backtracking line search with previous step length as i...
I'm currently trying to solve a system of (3) nonlinear equations of (3) variables which are the baryonic density, the isospin asymmetry and and the density of a fluid with the Broyden's method (a quasi-Newton method) included in the GSL. The problem is that I don't know how to avoid negative roots. I don't want them b...
I am trying to familiarise myself with SDEs and have been reading a few review papers on the topic. They leave the impression that a great deal of work has been put into solvers that are derivative-free. To my understanding this means that for a DDE like $$\newcommand\diff{\mathop{}\!\mathrm{d}} \diff X = f(X)\diff t +...
Gaussian quadrature improves on Newton-Cotes formulas by allowing the abscissas to vary along with the weights in order to integrate higher order polynomials. Can this idea be extended to numerical differentiation? To wit, can I choose a set $\{h_{i}\}$ such that $f'$ is much better approximated by a weighted sum of ev...
Suppose we have a very efficient way to perform $\ell_0$ "norm" compressed vs $\ell_1$ norm compressed sensing. Specifically, $\ell_0$ "norm" compressed sensing is $$\eqalign{ & \min \quad {x^T}Qx + {b^T}x + \mu {\left\| x \right\|_0} \cr & \text{s.t}:\quad Ax \le b \cr} $$ while $\ell_1$ norm compressed sensing ...
I have to create a strong scalability plot, which measures the execution time for a numberOfThreads =1,2,4,8,16 with size=1024. Here is the table with the results after execution: And here is the plot based on the table: I don't know exactly when is a plot strong scalable and if this plot is a strong scalability pl...
Appendix A of Liu, Baoyin, and Ma (2011) Equilibria, periodic orbits around equilibria, and heteroclinic connections in the gravity field of a rotating homogeneous cube shows an analytic expression for the gravitational potential of a uniform cube. I'd like to reproduce the orbit calculation using python, which will re...
Assume I have the following system of equations. I am trying to figure out if it's better for me to be solving this as a system of ODEs or as a system of DAEs. The real code can have up to a dozen or so equations, and the system is stiff (I am dealing with chemical kinetics, where the rate constants can vary by many or...
I have this method which computes the Fibonacci function: long optimized_p_fib(long n) { long i, j; if(n < 2) return n; #pragma omp task shared (i) { i = p_fib(n-1); } #pragma omp task shared (j) { j = p_fib(n-2); } #pragma omp taskwait return (...
I have a code I'm working on that involves solving a 1D Schrodinger equation using a Crank-Nicolson time step. The code is written in NumPy/SciPy, and I was doing a bit of profiling and discovered that the bulk of the simulation time is taken up with calls to the linear solver (spsolve in this case). I'm using a simp...
I have to find and plot a numerical solution for the following equation (I have to write a solver): $$u_{t} = (u^2 u_x)_x$$ with the following conditions $u(0,t) =0, u(1,t) = \sqrt{\frac{2c-2}{t}}, u(x,0) = 0$, where $c$ is a speed of the wave I try to use the following method: $$\frac{u_{m}^{n+1} - u_{m}^n}{\tau} = \f...
I have been pondering about this issue for some time... Say, I want to minimize a costfunctional $$ \tilde J(u) = J(v(u),u) = \frac 12 \int_0^T (v-v_0)^2 + \alpha u^2 dt $$ subject to $$ \dot v = v^2 + u, \quad v(0)=0. $$ Then, from the first order necessary optimality conditions it follows that at an optimal point $(v...
I try to solve the following mixed second order elliptic PDE in the domain $D=[0, 1]^2$ \begin{eqnarray*} v+\nabla p=&0 \quad &\text{in} \quad D,\\ \text{div}(v)=&1/2 \quad &\text{in} \quad D,\\ v\cdot n =&0 \quad &\text{on} \quad \partial D,\\ \end{eqnarray*} where $n$ is the unit outward normal vector fo...
Given a first order ODE $y'(x)=f(x,y)$ with the initial condition $y(x_0)=x_0$ such that it satisfies Picard thoerem of existence and uniquness, one can compute the solution by Picard iterations : $$ y_0 (x) \equiv y_0 \, ,$$ and $$ y_{n+1}(x) = y_0 + \int\limits_{x_0}^x f(t,y_n (t)) \, dt \, .$$ Computationally speaki...
Background I have a stiff system of 6 ODEs, represented in MATLAB as follows: system = @(t,x)[x(1,:).*x(2,:).*(-5.726882618492327e8)-x(1,:).*x(3,:).*1.467710449114545e10-x(1,:).*x(4,:).*3.012162507288153e12+x(3,:).*x(6,:).*1.137674873581712e12+x(4,:).*x(6,:).*5.703626484852603e12+x(5,:).*x(6,:).*1.656793950858653e9-x(1...
Assume, we have an $m\times n$ block matrix $M=\left[\begin{array}{c c}A&C\\B&D \end{array}\right]$, where $A$ is an $m_1 \times n_1$ matrix of rank $k_A$. $B$ is an $m_2 \times n_1$ matrix of rank $k_B$. $C$ is an $m_1 \times n_2$ matrix of rank $k_C$. $D$ is an $m_2 \times n_2$ matrix of rank $k_D$. Obviously, $m_1...
In an optical wavefront propagation problem, I need to do excessive Fourier-type computations: import numpy as np N=10000 input=np.random.random(N) x=np.linspace(-1,1,N) y=np.linspace(-2,2,N) X,Y=np.meshgrid(x,y,sparse=True) output=np.dot(np.exp(1j*2*np.pi*X*Y),input) However, the true kernel (here, the complex exp...
Let $\Delta\subseteq\mathbb R^2$ denote the triangle spanned by $(0,0)$, $(1,0)$ and $(0,1)$ and $$\mathbb P_r(\Delta):=\left\{p:\Delta\to\mathbb R\mid p(x)=\sum_{|\alpha|\le r}\lambda_\alpha x^\alpha\text{ for all }x\in\Delta\text{ for some }(\lambda_\alpha)_{|\alpha|\le r}\subseteq\mathbb R\right\}$$ for $r\in\mathbb...
I perform matrix matrix multiplications (between rank-3 and rank-2 arrays) in fortran using following subroutine, subroutine ab_c_dir1(n1,n2,n3,a,b,c) implicit none integer :: n1,n2,n3 real(rk) :: a(n1,n1),b(n1,n2,n3),c(n1,n2,n3) call dgemm('n','n',n1,n2*n3,n1,1.d0,a,n1,b,n1,0.d0,c,n1) end subroutine ab_c_d...
Let's suppose I'm numerically solving the Poisson equation for a delta function source: $$ \nabla^2 f(x) = \delta(x-x') $$ I can represent the Laplacian $\nabla^2$ using the finite difference method as a tri-diagonal matrix $A$. I can represent the delta function as a vector $b$ that is $0$ everywhere except at one poi...
I am studying optimization methods and I was able to understand and derive the search direction $$ p_k = r_{k-1} + \beta p_{k-1} $$ for Conjugate Gradient Method, with $$ \beta = -\frac{p_{k-1}^TAr_{k-1}}{p_{k-1}^TAp_{k-1}}. $$ In this expression $p_k$ is the search direction and $r_k$ the residual. Nevertheless, in a ...
I am trying to solve the system of linear equations: $AX=B$. For this currently I am using Intel MKL Pardiso solver. It works well when the order of $A$ is around $13500\times13500$ and below. Above that the solver gives wrong answer (perhaps I am giving wrong values of parameters required to be set before calling solv...
I wish to compute a certain function $\lambda$ (in my case an eigenvalue of the Laplacian) to a certain accuracy, which I wish to guarantee, if possible. I started with a finite element method. I know that in 2D there are way better methods, but my goal is to work on general surfaces, so that's why I work with finite e...
Is it a good criterion to stop iterative methods for solving non-linear equations, such as Newton-Raphson and good Broyden's methods, when $|x_k-x_{k-1}|<|x_k|\,reltol + abstol$ OR when $|f_k|<tolfun$, or should it be when $|x_k-x_{k-1}|<|x_k|\,reltol + abstol$ AND when $|f_k|<tolfun$? Until now, I was using the first ...
I implemented an algorithm for solving the Hankel transformation based on a paper. My problem is: It works very good for the functions suggested in the paper (as test functions), it works pretty ok for certain other test functions, but for other functions with known result it just produces garbage (result is far away f...
In Hesthaven book (Nodal Discontinuous Galerkin Methods) he uses SSP Runge-Kutta time method which is explicit. How can I change the explicit RK to an implicit one?
I have to solve many times a nonlinear system of the form $$f(x) = b^{(n)}$$ inside a loop. The function $f$ is expensive to compute and I do not have its jacobian, so I have tried the good Broyden's method. As the initial guesses of the solution, $x_0^{(n+1)}$, and the jacobian, $J_0^{(n+1)}$, at the (n+1)th iteration...
I have to use an iterative method (Newton-Raphson, modified Newton and Broyden) to solve a system of nonlinear equations $f(x)=0$. Every unknown $x_i$ is bounded between $l_i$ and $u_i$, i.e., $l_i<x_i<u_i$, and evaluating $f$ if any of the unknowns goes out of its bounds would give an error. Which is the best techniqu...
I am trying to solve the Lamm eqn numerically, using 1-D FEM. What I observe is spurious oscillations at one boundary ($r_b$), which quickly leads to unreasonable values over the entire range. I am looking for advice on how to modify the FE formulation to eliminate these oscillations. The Lamm eqn is $${\partial C \ove...
I have to work with values such as 1e-15 in my code but I can't. Indeed, because of low precision these values are equivalent to 0. Any ideas?
I'm working on a 2-D planar finite difference code. My differencing scheme at the boundary nodes involves introducing ghost nodes in the computation. My code also involves a multi-dimensional derivative: $$ \frac{d^2u}{dxdy} \approx \frac{u_{i+1,j+1} - u_{i+1,j-1} - u_{i-1, j+1} + u_{i-1,j-1}}{4\Delta x\Delta y} $$ Th...
So our team has been able to code up a BiCGStab implementation for a class project, and we'd like a potential example problem to try it out on. So far, we've talked about a 1D Laplacian with Neumann boundaries (so the matrix becomes nonsymmetric), but I am strongly inclined to demonstrate at least a very slightly more ...
I have a binary full-rank matrix of size, say, $25 \times 50$. I need to count how many subsets of its columns form matrices with a full column rank, i.e. all the columns in the subset are linearly independent. Straightforward approach would be to iterate over all subsets of columns of size up to $25$, and then check c...
I'm trying to solve the ODE of motion: $$ \begin{align} x''=&\ -myu \frac{x}{r^3} \left(1+\frac{3}{2} {J_2} \left(\frac{{r_{\text{eq}}}}{r}\right)^2 \left(1-\frac{5z^2}{r^2}\right)\right) \\ y''=&\ -myu \frac{y}{r^3} \left(1+\frac{3}{2} {J_2} \left(\frac{{r_{\text{eq}}}}{r}\right)^2 \left(1-\frac{5z^2}{r^2}\rig...
I am working on mesh generation and optimization and encountered this problem. For example, in the figure below, we have the edge-vertex connectivity: 0-1 1-4 4-5 2-5 3-2 0-3 1-2 1-6 7-6 4-7 How to generate the faces in terms of face-vertex connectivity? For this case, the faces can be "generated" by visual inspectio...
I am trying to code a scalable parallel AMR for unstructured grid. There seems to be three approaches for this a) Store some global grid info on each processor and partition with parmetis (The easiest approach I am pursuing). I have never used ParMetis before (just metis) so I do not know how one would be able to read ...
In our university some Ph.D students for computational methods prefer FORTRAN over MATLAB. I can't understand why? What is the difference between them when are used in computational methods like spectral methods, FEM or BEM? Please tell me which one do you use and why? and what language do you recommend me to learn? I ...
Kahan summation applies to summation problems, but not to three-term recurrence relations. However, a three-term recurrence shares many of the features of a summation-albeit with a rescaling step at each iteration. Hence there seems to be hope for a Kahan summation for three-term recurrences. Has this idea been worked ...
I'm trying to solve an iterative problem that includes an implicit (backwards) Euler method to find successive time values for a given function. The numerical problem is shown here: $$ \begin{aligned} \frac{u_{r,s+1}-u_{r,s}}{\Delta t}&+u_{r,s}\frac{u_{r+1,s+1}-u_{r-1,s+1}+u_{r+1,s}-u_{r-1,s}}{4\Delta x}\\ &\quad+\fra...
I have the elliptic problem $$-\Delta u = 1,\,\,\Omega\subset\mathbb{R}^2$$ with $u=0$ on $\partial\Omega,$ with $\Omega=[-1,1]^2\backslash([0,1]\times[-1,0])$ and I want to estimate the $L_2$ error of linear finite element method on triangular mesh, if $u_h$ is the finite element solution and $u$ is the exact solution...
I have encountered the term cell "Cell averaged derivatives" and "Taylor series expansion using cell averaged derivatives about centroid" in the context of polynomial representation in any cell (computational element with some higher order interpolation polynomial nodes). Here is the link to the below paper: http://dep...
This question was moved from Cross-Validated: https://stats.stackexchange.com/questions/274042/pseudoinverse-of-large-sparse-matrix-in-r I am trying to calculate the pseudoinverse of a large sparse matrix in R using the singular value decomposition. The matrix is roughly 240,000 x 240,000, and I have it stored as type ...
I'm learning to use OpenCL to optimize some of my simulations. I realized that I need some sort of Graph-clustering or graph-partitioning to exploit efficiently local memory for un-ordered meshes. example: I implemented elastic cloth simulation with regular mesh of 4-bonded vertexes, which I can separate manually to lo...
Consider a fluid flow simulation in a pipe. At the outflow, instead of explicitly imposing a boundary condition, I linearly extrapolate information from the interior (for velocity components). This will translate to $$\frac{\partial ^2 u}{\partial x^2} =\frac{\partial ^2 v}{\partial x^2}=\frac{\partial ^2 w}{\partial x...
I am trying to solve a coupled system of ODE's using MATLAB's bvp4c function. I want to impose the condition that $$\int_{0}^{\pi} y_{1}(t) y_{1}(t) dt = 1,$$ where $y_{1}$ is the first state variable. Another post suggested adding a additional equation to the system of ODE's. Namely, $$I(t) = \int_{0}^{t} y_{1}(s) y_{...
I have a chamber full with a fluid flowing horizontally in laminar regime from one side to the other. It carries a suspension with concentration $c$. This suspension also falls to the bottom of the chamber with settling velocity $\mathbf{v_s}$. When it reaches a critical concentration $c_{max}$ at the bottom, it start...
I have an optimization problem that I'm trying to cast as a linear program. However, I have an objective function of the form $$\begin{array}{ll} \text{maximize} & a_1 x_1 - a_2 \lvert x_1\rvert\\ \text{subject to} & \color{gray}{\text{(constraints)}}\end{array}$$ I tried doing the classic linear reformulation using a ...
How can I estimate the error of a result obtained by using the trapezoidal rule if I don't have the function that describes my problem? The only thing I have is discrete points.
I wanted to know if practically the inverse radon transform operation is considered linear and would be a good candidate for the application of compressed sensing. To my understanding it should be linear since it is just an integral transform, but I have only basic knowledge about compressed sensing and the inverse rad...
I am a Mechanical Engineering grad student, currently working on a project which will be scaled up in the new future to require quite some processing power. I am using C++ for the code that I have, and later plan on writing a parallel version of the code for running on distributed memory HPC systems. I do not possess a...
I am implementing a Trust-Region method using Dogleg for the search direction defined as $\tau p^U$ for $0 \leq \tau \leq 1$ and $p^U + (\tau -1)(p^B-p^U)$ if $1 \leq \tau \leq 2$. To compute $\tau$ we have to solve the following equation: $\| p^U + (\tau - 1)(p^B-p^U) \|^2 = \Delta ^2.$ I tried to expand it in order t...
I am trying to make the jump from a FEM plot of a static load applied to Mindlin laminate plate to a surface visualization of various Mode Shapes of the Laminate Plate. For that, I understand that the two big steps are: developing a Mass Matrix $[M]$; and getting the eigenvectors and eigenvalues $[V]$ and $[D]$. Whil...
I read ADER WENO Finite Volume scheme for hyperbolic conservation laws with source term. I want to implement this method in Matlab coding. I got some problems in coding during to computation of numerical flux. Please help me the Matlab coding $$u_t+f(u)_x=S(u,x,t),\; u(0,x)=u_0(x),\; x\in \mathbb{R}, \;t>0,\;u(t,-\in...
For the equation $\frac{\partial u}{\partial t}=-(-\Delta)u$ with zero boundary condition using finite element method. Applying the corresponding weak formulation and taking $v=\phi_{j},j=1,2,...,N$, We obtain the following equation. $$\sum\limits_{i=1}^{N} \frac{du_{i}}{dt}\int _{\Omega} \phi_{i}\phi_{j}d\Omega=-\sum...
I'm attempting to solve a convex optimization problem where one of the constraints is $$\|M\|_* \leq a$$ where $\|M\|_*$ denotes the nuclear norm of matrix $M$. I'm using CVXOPT in Python to solve this as a linear program (LP), but the nuclear norm (sum of singular values) isn't a nice linear constraint. How can I for...
I have a system of parameterized ODEs that I would like to solve using MATLAB and its ode45 solver, and was wondering if it is possible to perform such a task in parallel. For example, I have a simple model of a rocket falling in gravity, where I would like to try different parameter values of tburnstart and tburnend, ...
I have a sample of 100 particles with their 3D positions and velocities. I want to decompose the velocity vector field to its curl free and divergence free components. Is it a feasible to do so for the sampled data using Python, Matlab or Mathematica?
I want to find an expression for the stability of the nonlinear Poisson equation. I know about von Neumann stability analysis which applies to linear equations as far as I know. Any suggestion how to analyse the stability? The equation I am trying to solve is: $$-\frac{\partial ^{2}\phi}{\partial \tau^{2}}+\alpha\frac...
I am trying to estimate the position of a point $P$ in Matlab. I have $n$ access points (AP) at known positions ($n>2$) as well as the distances to the point $P$ from each AP. These distances all have a distance error. I know how to solve this using multilateration if the circles from the known nodes would intersect, b...
I have a dataset that is slowly changing, and I need to keep track of eigenvectors/eigenvalues of its covariance matrix. I've been using scipy.linalg.eigh, but it's too expensive, and it doesn't use the fact that I already have a decomposition that's only slightly incorrect. Can anyone suggest a better approach to deal...
I'm currently trying to get into this topic. I've learned that the basic scheme for the advection problem ($D_{x}u+a*D_{t}u=0$) can be solved in a scheme like $$ M^{k}\frac{d}{dt}u^{k}_{h}-(S^{k})^{T}au^{k}_{h}=-(au_{h})^{*}\psi(x^{k}_{r})+(au_{h})^{*}\psi(x^{k}_{l})$$Here, we have $$ M^{k}_{ij}=(\psi_{i},\psi_{j}), ...
We are using Kitware VTK to visualize our models. When we display streamlines, it sometimes happens that a single streamline is left out. This can be especially seen when duplicating a model several times, so that there is a model that has several components that look alike with the same distance between each other. Us...
Given $\omega$ I want to compute the vector $q=(u,v)$ such that $$ v_x - u_y = \omega, \qquad u_x + v_y = 0, \qquad \textrm{in } \Omega $$ and $$ u n_x + v n_y = 0, \qquad \textrm{on } \partial\Omega $$ I am looking for a finite element method to find such a vector field. I can introduce a stream function $\psi$ such t...