instruction
stringlengths
43
28.1k
Can you provide a hash functions $F(x) | F(x) = F(\overline{x}), x \in {\{0;1\}}^n$ $\overline{x} $ is $x$ where all bits are swapped: $0 \rightarrow 1, 1 \rightarrow 0$ Basically it will help me improve my MAX-CUT algorithm
I have a problem of the form, \begin{align} minimize_{y} maximize_{x}&\quad x^T y - y^T (B\odot x x^T) y\\ s.t. &x\in [l,u]\\ &Ay=b \end{align} How to efficiently solve this problem? $B$ is a semidefinite matrix. What I have done: you can dual the inner problem, and get a semidefinite problem with two sdp variabl...
I would like to incorporate a CFD topic in a project I currently have. The deadline is a little less than a month from now. Basically, what I would like to do is solve some equations and simulate fluid behavior. The programming language I will use to accomplish this in is C, however I intend to rely on MATLAB for later...
I'm trying to solve a nonlinear partial differential equation \begin{equation} L(u_{xxtt},u_{xx}u_{tt},u_{xt}^2,u_{xt},u_{tt})=0 \end{equation} using finite difference methods. In order to remove the second derivatives with respect to time, I substitute \begin{equation} v := u_t \end{equation} such that it becomes \beg...
The problem I have may be really simple, but still getting a hard time solving it. So I have the Euler rotation equations: $$I_{1}\dot{\omega}_{1}+\left(I_{3}-I_{2}\right)\omega_{2}\omega_{3}=\lambda_{1}$$ $$I_{2}\dot{\omega}_{2}+\left(I_{1}-I_{3}\right)\omega_{3}\omega_{1}=\lambda_{2}$$ $$I_{3}\dot{\omega}_{3}+\left(I...
I am starting to dabble in MPI. I am fairly new to this area and I am currently reading the MPI standard. I would like to write my first MPI program, a simple hello world program, on a cluster that I have. I am not sure if anyone is familiar with the IBM bladecenter. Supposedly, there is a midplane that connects all o...
In N queens problem https://en.wikipedia.org/wiki/Eight_queens_puzzle, trying to find solution by backtracking encounters difficulties quite fast (even for SWI-Prolog, http://swish.swi-prolog.org/example/clpfd_queens.pl, which solves N=100 in 0.2 sec, entering N=150 in the link above did not reach a solution in a reaso...
I do a lot of general processing of data on my desktop computer. It can be stuff like extracting timeseries of point measurements from a large number of NetCDF files, or converting csv-files into binary or making a lot of plots. My question is, would it be useful to have a Xeon Phi for this kind of work? I try to use t...
Ok so I'm a complete beginner in computational modelling (I use analytical methods of physics typically) but I would like to model an anisotropic, aperiodic (but not random) finite array of metallic nanorods, all of which have their long axis orientated in the same direction as eachother, but this direction can be comp...
I have 2 pandas datasets which have 'RF' field in common. The optionsdata variable is ~60K, which map to at most the histdata fields of 5K. Using np.where is incredibly slow: for j in range(0,len(optionsdata)): optionsmap[j] = np.where(histdata.ix['RF'].str.match(optionsdata.RF[j]))[0][0] Is there a much faster ...
Suppose we use a preconditioned iterative solver for a linear system. If the initial state for the solver can be chosen very close to the exact solution - does this reduce requirements for the preconditioner?
I just got a new Macbook and decided to install everything from scratch instead of migrating. Previously I've always installed SciPy etc. through MacPorts, but lately MacPorts as a whole seems not to be as cleanly maintained as it once was, and I spend a lot of time tracking down problems with it. I also generally used...
Hi I have a code below that solves non linear coupled PDE's given Dirichlet boundary conditions. However I need to implement periodic boundary conditions. The periodic boundary conditions are troubling me, what should I add into my code to enforce periodic boundary conditions? Thanks for the help. Note, $t\geq 0$ ...
I have the following two PDEs which I want to check for stability: $$u_t= u_{xx} , \ u(x,0)=1 , \ u_x(1,t)=-hu^4(1,t) , \ u_x(0,t) = 0 $$ $$u_t = u_{xx}-\sin(x+t)+\cos(x+t) , \ u(x,0)=\cos(x) ,\ u_x(1,t)=-hu^4(1,t)-\sin(1+t)+h\cos^4(1+t) , \ u_x(0,t)=-\sin(t)$$ For the first I got that $d/dt (u,u) = d/dt \int_0^1 u^2 d...
Consider the following eigenvalue problem \begin{equation} \mathcal {L} x(s) = \lambda x(s), \end{equation} where \begin{equation} \mathcal {L} = \alpha \partial^4_s + (s^2-1)\partial^2_s + s \partial_s + 1, \end{equation} with $\alpha = \rm{const}$ and $s\in[0,1]$. In order to find the eigenvalues and the eigenfuncti...
What are the state of the art methods for fast 2D convolution approximation? I'm familiar with SVD based multiplication and cross approximation approaches, but would be thankful to get additional references. The kernel size is typically ~3x3 - 11x11, not separable, with input matrices from sizes ~200x200 - 1000x1000. T...
There are many methods for diagonalizing matrices, probably the most widely used is the combination of Householder transformations and the QR algorithm. Is there any superior method for diagonalizing (large, non-sparse)real symmetric matrices? Superiority can be a bit muddy, so I define it as fast, numerically stable, ...
It is a commonly known fact that the Rayleigh Quotient converges cubically (1), while the Power Iteration may converge slowly if the difference between the dominant and second-dominant eigenvalue is small. Knowing this, when would it ever be beneficial to use the Power Iteration over the Rayleigh Quotient Iteration? T...
If there is an $(n+1)$-dimensional integral of the form $$ \int_{[0,1]^{n+1}} f(x, y)\,\mathrm{d}^n x \,\mathrm{d}y,$$ normally one would evaluate this using a multi-dimensional integration library over the whole domain, $[0,1]^{n+1}$. But are there some conditions where it might make sense to perform the integral over...
In CVX, I encounter a problem. I want to multiply a Matrix of 2x4 with its transpose. I know the result must be positive definite. However, it couldn't let me do the multiplication directly. Says: Disciplined convex programming error:Only scalar quadratic forms can be specified in CVX. What can I do? cvx_begin vari...
I am working on implementing the Fourier beam propagation method in C++. I am really more of a programmer than a physicist but I think I have a good understanding of what I am trying to do. Here is what I am trying to implement. Two questions. In the flow chart he says you should perform the diffraction and after t...
I am in the process of building a robotics physics engine. I have been using the Linear ODE $x' = Ax + b$ for the core of my physics integration, but have never found a really good solution method for it. My problem gets harder than the standard ODE solution because my A matrix is singular. Here is an example of an $A...
I need to calculate the lagrange polynomial which approximates $e^x$ at $101$ points, the points $\frac{k}{101^2}$ for $k\in\{0,1,2\dots 100\}$. I tried the following code: import java.math.*; import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; public class interpolation { publi...
I want to solve PDE system, which consists of Poisson equation, continuity equations for electron and hole with drift-diffusion equation numerically, by using method called Newton's method. This method is explained in several literatures, including https://nanohub.org/resources/1565/download/ddmodel_solution_details_wo...
I need to solve a set of 5 PDEs for functions $u(x,t)$. I looked up the Matlab function pdepe. It looked perfect for my case, until I read the line: $f(x,t,u,\partial u/\partial x)$ is a flux term and $s(x,t,u,\partial u/\partial x)$ is a source term. The flux term must depend on $\partial u/\partial x$. In my probl...
When we create numerical models of a real-world system, we usually go through a few phases (from Abramowitz 2010): a perceptual model, where we consider the relevant components of the system a conceptual model, where we consider the relationships between those components a mathematical model, where we come up with equ...
In my view, it is needed, To save computational time. To define accurate boundary conditions at interface where properties changes drastically. To solver 2 phase problems as single phase only. To capture breaking and joining of droplets/splashing. Are there any other reasons which I am missing? Please guide. Thanks
I am trying to simulate an optic-fiber sensor (in-fiber interferometer) to study its respond to temperature. The method I am using is finite-difference time-domain (FDTD), and I come out with a large memory usage problem. The wavelength of the light source centered at 1.55μm while the optical fiber has diameter of 125μ...
How to numerically find the solution for $a$ and $b$ of this equation $$\sum_r \frac {\mathrm B_{z_r}(a+m_r+1,b)}{\mathrm B_{z_r}(a+m_r,b)}=K$$ where $m_r$ are non-negative integers, $0<K<1$, $0<a$, $0<b$, and $\mathrm B_{z}(a,b)=\int_0^zx^{a-1}(1-x)^{b-1}dx$ is the incomplete beta function
I am using the method by Brandt in the FAS Multigrid algorithm to estimate the truncation error in a 1-D flow problem and then use that as the basis for generating a mesh(r-adaptation) in 1-D. The process is standard, in that, transform the equations to a computational domain $\xi$, perform/run computations and map th...
Given some sparse unitary square matrix $A$ ($dim=2^n$ if it matters), is there an algorithm to decompose $A$ into a Kronecker/tensor product of smaller unitary matrices? In other words: decompose unitary $A$ into $$A=U_1 \otimes U_2 \otimes ... \otimes U_k$$ where each $U_i$ is individually unitary and $\otimes$ deno...
Let $A\in \mathbb{R}^{n\times n}$, symmetric and positive definite. Suppose it takes $m$ units of work to multiply a vector by $A$. It is well known that performing the CG algorithm on $A$ with condition number $\kappa$ requires $\mathcal{O} (m\sqrt{\kappa})$, units of work. Now, of course, being a $\mathcal{O}$ stat...
Let $A$ be positive-definite and $C$ diagonal positive-definite, consider the problem of solving the following equation for $\bf x$ $$A{\bf x}+C\begin{bmatrix} e^{x_1} \\ \vdots \\ e^{x_n} \end{bmatrix}=b.$$ I believe nonlinear conjugate gradient can solve this, however the nonlinear part is pretty benign as far a...
I'm a bit confused about the relationships between these two approximation methods mentioned in the title. Does this kind of interpolation also belongs to the field of spectral methods? Are the Lagrange interpolants we get from using the roots of orthogonal polynomials also orthogonal? It's likely to get mixed with...
In PETSc, I need to generate a random number between 1 and 0. With the include cstdlib, the classical trick is: (double)rand() / (double)RAND_MAX In PETSc, the constant RAND_MAX does not seem to exist. Is there a work around? Though it is ugly, I plan to do something similar to: (rand() % 10000) / 10000.0
I am working on a model in COMSOL and I am usin different meshes from coarse to fine keeping the other parameters constant. And, I got different maximum velocities for all the meshes. What can I do to achieve similar maximum velocities for all the simulations?
Note: this question is not strictly related to Matlab or any other environment (even though I would prefer that you refer to my Matlab code). I've n = 10000 equally spaced elements between -pi and pi in an array produced like this (in Matlab): n = 10000; x = linspace(-pi, pi, n); Then I create a second array x_r, ...
Setup (complete, but all very standard): My problem is how to best calculate the cumulative integral of a function which comes out of Spectral Collocation with a chebyshev basis. Take some function $f : [0, \bar{z}] \to \mathbb{R}$ approximated by $$ f(z) \approx \sum_{n=0}^{N-1}d_n T_n(z),\, z \in [0, \bar{z}] $$ whe...
The solvepde function was introduced in MATLAB R2016a. I am able to solve my system of PDEs if there are no time delays involved. Does anyone know how to include time delays in the solvepde function?
I need to compute the two-sided (bilateral) Laplace transform of a numerically given function $F$, $$ I(t) = \int_{-\infty}^{+\infty} {dx} \, e^{-x} \, F(x + t) ~, $$ where $F(x)$ has some sharp features, e.g., at $ x = \{ 0, x_p, \cdots \} $, has finite support, and vanishes sufficiently fast for $ x < 0 $ to prevent ...
I have a one-dimensional set of points, i.e. $(n,y_n), 1\leq n \leq N$. I want to fit them with a linear combination of $k$ rectangular functions in a least-squared-error sense. Each rectangle is parametrised by a left edge, right edge, and height. It is similar to the Lebesgue sum but I am looking at horizontal strips...
I have a simple question that I wasn't able to find an answer to. I have a function f(x) where x is some vector, for example: function f=f(x) f=x.^4; end Then I want to integrate with bounds as vectors: x=1:0.1:10; x_0=2*ones(size(x)); g=integral(@f,x_0,x); and I want to get g as a vector g(i)=integral(@f,x_0(i),...
I would like to fit a diffusion coefficient as function of e.g. salt, pH etc. If I use a linear combination of all variables, I will have to apply constraints because the model fails, if the diffusion coefficient will get too large or negative. I was wondering if there exists a function that behaves similar to the logi...
I want to write a MATLAB code for Roe solver for 1D shallow water equations. Is there anyone who can help me with that?
I am going to calculate a trajectory, by using a pre-calculated vector field. The values of the field are known on a grid which is quadratic in the horizontal direction, un-evenly spaced in the vertical, and evenly spaced in time. I'm planning to use a 4th order Runge-Kutta integrator, and my question is if I should si...
Recently, I took a course on numerical methods where we learned about Galerkin's Method of Weighted Residuals. We were told that it forms the basis of the Finite Element Method . However, in most introductory texts I've seen on FEM, they start with a simple example where they manually write out the equations to minimiz...
How can I make a scatter plot like the following, where the density of points represents the magnitude of the scalar field at that point. Consider for example the probability density for an atom: I managed to plot something like this as a color plot (see my question and the pictures here: https://stackoverflow.com/que...
In elementary chemistry textbooks you often have pictures like the following one: Are there any conventions how to get them? I am not sure, but I guess that it are contour plots with only one iso-surface of constant probability density $|\psi|^2$ such that the (integrated) probability for an electron to be inside of o...
I am trying to solve Travelling Salesman Problems using tabu search. I have been able to successfully find "near enough" optimal solutions (as well as one optimal, yay!). For the moment I am using sub-tour reversal as the local search precedure. The basic gist of it is similar to 2-opt, but rather than swapping two cit...
The documentation of PETSc shows an example of usage: PetscRandomCreate(PETSC_COMM_SELF,&r); PetscRandomSetType(r,PETSCRAND48); PetscRandomGetValue(r,&value1); PetscRandomGetValueReal(r,&value2); PetscRandomDestroy(&r); In the example random 1, we can find also the use of PetscRandomSeed. However, it seems n...
I've got an elliptic problem in a domain with two materials in a checkerboard arrangement. Both materials are highly dissimilar, being one much more compliant than the other. If I use classic linear lagrange finite element, because of the corners of the checkerboard, there will be singularities that will make the solu...
I understand the basic idea of imaginary time propagation method: The wavefunction $\psi(x,t)$ as a superposition of energy eigenstates $\phi_m(x)$: $$ \psi(x,t)=\sum_m \phi_m(x)e^{-iE_mt/\hbar} $$ In imaginary time, ${t}\rightarrow{-it}$, $$ \psi(x,-it)=\sum_m \phi_m(x)e^{-E_mt/\hbar}=e^{-E_ot/\hbar}\bigg(\phi_o+\phi_...
I would like to know if I should switch to OPENFOAM for my task. I work only with Cartesian grids, right now in 2d, rectangular domains only. If $\mathbf{w} = (w_1, w_2)$ and suppose I want to solve $\partial_t(\mathbf{w}) = \nabla(\mathrm{div} \mathbf{w}) = \mathbf{f}$ subject to Dirichlet boundary condition and an...
Nocedal and Wright on Conjugate Gradient Methods, p. 123, describe a restart strategy ... whenever two consecutive gradients are far from orthogonal $\qquad {{| \nabla f_k^T \ \nabla f_{k-1} |} \over { \|\nabla f_k\|^2 }} \ge \nu $, with $\nu$ typically 1/10. Can anyone comment on CG with such restarts, or point to t...
A CSV file is characterized by a header, describing the n datarows to come. The header is a text string separated by a separator. A CSV header might look like (C1) Date;Time;ZIP-Code;Address;Temperature Assume we have a second CSV file (C2) with this structure: Date;ZIP-Code;Address;Temperature C1 and C2 are similar,...
Suppose I have a large, sparse, $m \times n$ matrix $A$, with $m \gt n$ and $\text{rank}(A) = n$. I wish to solve $Ax=b$. Suppose I know that $A$ has the following characteristics: $A$ is somewhat diagonally-dominant (it may have a few side-bands offset quite a bit from the main diagonal, and a few rows do not fit th...
In numerical fluid dynamics there are field methods like finite-volume, finite-element, etc. and particle methods like Smoothed-Particle-Hydrodynamics – SPH and others. Both approaches have advantages and disadvantages depending on the application. Both, in principal completely different approaches, can be combined usi...
The 2-norm condition number can be easily extended to rectangular matrices. I'm wondering if the inequality for the product of matrices still holds in that case, i.e., $\operatorname{cond}(AB) \leq \operatorname{cond}(A)\operatorname{cond}(B)$
I wonder what is the difference between both functions. In C++, the difference between new and malloc is easier: new allocates memory by calling the constructor. What about PETSc ? In the example, it seems to be pretty close: in dm/examples/tutorials/ex6.c: struct _p_FA { MPI_Comm comm[3]; PetscInt xl[3],yl[3]...
I recently heard that in Linux, /dev/random and /dev/urandom are pseudo random number generators but not true random number generator. So I am curious to know the difference between pseudo & true random number? In other words What is the difference between pseudo-randomness & true-randomness?
I am interested in solving a sequence of linear systems of the form: $$A x_i = b_i$$ That is, all the systems use the same matrix $A$ but they have different right hand sides. The matrix $A$ is sparse symmetric positive definite. I am currently using CHOLMOD to solve each system. Obviously, I factorize $A$ once (Chole...
Suppose $A\in\mathbb{R}^{n\times n}$ is a banded matrix, i.e., a matrix with all of its nonzero elements on the main diagonal, i.e., $\alpha_{i,i}\neq 0$, the first superdiagonal, i.e., $\alpha_{i,i+1}\neq 0$, through the $k$-th superdiagonal, i.e., $\alpha_{i,i+k}\neq 0$, the first subdiagonal, i.e., $\alpha_{i-1,i}\n...
For my program assignment I need to write a preconditioned steepest descent algorithm. I have psedo-code from my professor which is here: From reading in my text on this method they say that $P$ is the preconditioned matrix but they do not define it in any way shape or form. I am not sure at all, but by my professors p...
In the (iterative) Conjugate Gradient (CG) algorithm: https://en.wikipedia.org/wiki/Conjugate_gradient_method The initial search direction $p_{0}$ is set to the initial residual $r_{0}$. But I can't see why this choice? Can I get this choice of $p_{0}$ from any of the equations presented in the article? Thanks!
I am working on an astrophysical research in which we relate the cumulative number of Damped Lyman Alpha HI clouds/galaxies, namely their number densities, $\frac{dN_{DLA}}{dz}(>M, z=0),$ to the hosting Dark Matter halo mass function, $\frac{dn_{h}}{d(\log M)}$, and the incidence cross section area, $\sigma_{DLA}$, in ...
I have a working C++ function: /// Structure for surface nodes // Each node has a current x- and y-position and a reference x- and y-position. struct nstruct { /// Constructor node_struct() { x = 0; y = 0; x_ref = 0; y_ref = 0; Ax = 0; Ay = 0; } /// Elements double x; // current x-position doubl...
I am in the process of collecting material for a class in computational methods. It will include introductions into numerical methods for ordinary differential equations (Runge-Kutta methods, multi-step methods) and parabolic and hyperbolic partial differential equations (finite differences, spectral methods, finite vo...
I've been learning CFD theory for 4 months (which includes FEA, FDM AND FVM) and now I want to start running simulations. As a novice to CFD software, I would appreciate some advice on where to start, e.g., OpenFoam, Matlab, Fortran? (I am comfortable with programming and learning coding languages).
I wanted to clarify the idea of the exact line search in steepest descent method. An exact line search involves starting with a relatively large step size ($\alpha$) for movement along the search direction $(d)$ and iteratively shrinking the step size until a decrease of the objective function is observed. Is this cor...
Given a domain $\Omega$ with 2 subdomains $\Omega_1,\Omega_2$ as figure below Level set equation $$ \partial_t\varphi + U\cdot\nabla\varphi =0 $$ $U$ is velocity only presents inside $\Omega_1$. We assume $U$ is irrotational, i.e. $\nabla \times U=0$, which implies that the velocity field can be derived from a potentia...
So given an objective function $f({\bf x})$, I would like to include a positivity constraint when I perform the fixed point iteration: $${\bf x}^{(t+1)}={\bf x}^{(t)} - \text{H}_f^{-1}\nabla f({\bf x}^{(t)}),$$ for ${\bf x}^{(0)}>{\bf 0}$. The best way I've found to do it is to add a log barrier to the objective functi...
Given the advection equation for an incompressible flow field $$\frac{\partial c}{\partial t} + \mathrm{Pe} \frac{\partial c}{\partial x} = 0$$ what would the best method be for discretizing this without introducing any numerical diffusion or oscillations? Specifically when we have step changes in boundary conditions, ...
Assume I know eigen-pairs $(\epsilon_i,\vec\phi_i)$ for matrix operator $\hat H$ that $ \hat H \vec \phi_i = \epsilon_i \vec \phi_i $ Now I have slightly perturbed $\hat H' = \hat H + \hat R$ were perturbation $\hat R$ is small with respect to $\hat H$ (in some sence, e.g. Frobenius norm ?). Now I would like to find ei...
I asked a similar question on the Mathematics stack exchange here without much success, so I thought I'd ask it with a more practical bent here. Suppose we have a Hermitian matrix $H$ with (for the moment) distinct eigenvalues. Let $\{u_1,u_2,\ldots,u_n\}$ be an orthonormal eigenbasis. Most linear algebra packages I kn...
There are two independent tetrahedral FEM grids. Second grid is subset of the first. By subset, I mean: nodes from the second grid are exactly in the same positions as some nodes from the first grid. The numbering of nodes is completely different in both grids. I need to renumber nodes from the second grid according to...
this is a classical problem, but I need help to pinpoint what I am missing. Problem: In MATLAB (exp(1) + 10^12) - 10^12 gives you a double which equal to e, up to 5 correct digits. But I thought it would be 4. One has exp(1) + 10^12 = 1.000000000002718e+12, where 1.000000000002718 contains 16 digits, the precision w...
I have a function evaluated on a regular 5D grid with 21 points per dimension (so $21^{5}$ points total). I need to evaluate the integral of the function over all 5 dimensions, so I was planning on using one of the composite Newton-Cotes formulae (i.e. trapezium rule, Simpson's rule, Boole's rule etc.) I'm wondering: ...
Given a set of integers $\{l_1,l_2,\ldots,l_n\}$, where each integer is associated with a set $m_k\in\{-l_k,-l_k+1,\ldots,l_k\}$, I need to find all combinations $\{m_1,m_2,\ldots,m_n\}$ that sum to a given integer $M$. As an example, let's say the input is $\{1,3\}$ and $M=2$. This means that $m_1\in\{-1,0,1\}$ and $m...
I wrote a number of 1D/2D FE and FD programs as a bachelor student, but the main problem I continually came into contact with was gradient shocks related to convection/diffusion problems in convection-dominated flows. From my limited research this seems to be an inherent problem in continuous Galerkin FE methods. Now I...
It is necessary for me to find the shape functions on $L^2(\Omega)$(piecewise constant functions), I searched a lot but that, could not find anything, all of them are about higher degree polynomial. If we define the space as follow: $${\cal Dp0}=\{v \in L^2(\Omega):v|_T \in {\cal p0(T)}, \forall T \in {\cal T}\}$$ whe...
I try to familiarize myself with iterative eigenvalue solvers such as Lanczos. So I tried rewrite it to python directly according to wiki. But it doesn't seem to work. The problem: it approximates quite well the largest eigenvalue $\epsilon_{max}$ of matrix $A$ but the rest of eigenvalues obtained by solution of proje...
I am trying to minimize a non-linear vector-valued function in MATLAB. As a test case for my code, I try to minimize a function whose solution I know apriori. The problem is that one of the solutions is widely distributed in scale. They are [175,164,854,3.7e5,6000]; As you can see, the 3.7e5 has a wide difference in ...
I just knew how to do Newton-Raphson iteration in time-independent 1D nonlinear differential equation. Then I applied to time-dependent 1D nonlinear differential equation, and I got confused. Below is just test time-dependent 1D nonlinear differential equation I want to solve (I just made this up from heat equation, to...
I would like to solve the following optimization problem \begin{align} \min_{x\in [0,1]^n} x^T p+ \frac{1}{2\lambda} x^T Q x \end{align} $Q$ is a positive semidefinite matrix. $\lambda>0$ is a constant (a real number). I want to solve this problem repeatedly, with the slight change of $p$ and $Q$ in each iteration. Th...
I know that in outflow boundary we assume a zero normal gradient condition and use upwind scheme for approximation. However, I saw this sentence in a book which I do not understand; "Convective fluxes are usually assumed to be independent of the coordinate normal to an outflow boundary." What does it exactly mean and w...
In standard finite element method, when we want to find $L^2$ error of a solution, we only find the error on Gaussian points that are inside of each triangle, for $DG$ method can we do this in a same way or we should add some boundary error term, because of the jump?
Recently, I came across a comment claiming that almost all researchers doing Monte Carlo methods are doing it wrong. It went on to elaborate that merely choosing different seeds for different instances of a PRNG such as the Mersenne Twister is not sufficient to ensure unbiased results as bad collisions can occur. The W...
I am kind of new in finite elements and I am solving simple "Poisson nonlinear" problem. $- \nabla ((1 + u^2) \nabla u) = f$ $u = 0 \ \text{on} \ \Omega $ I am using Newton solver, where I have defined step as following $J = s * ( -g )$, where $ J = \int (2 \delta u \nabla u_h) \nabla v + (( 1 + u_h^2) \nabla \delt...
I need to solve a tridiagonal system (positive definite, diagonally dominant) $Ax = b$ in a time stepping loop. $A \in \mathbb{R}^{N \times N}$ remains constant but $b$ changes during each time step. I was thinking which of the following would be faster : Compute and store $\mathbf{z_i}$ that solves $A\mathbf{z_i} ...
I am solving an unsteady flow using the dual-time Navier-Stokes equation in which I write my momentum equation as: $$\frac{\partial u}{\partial \tau} + \frac{\partial u}{\partial t} + \frac{\partial u^2}{\partial x} + \frac{\partial uv}{\partial y} = -\frac{\partial p}{\partial x} + \frac{\partial^2 u}{\partial x ^2}...
I am trying to figure out how to deal coupling. I am trying to model a polymer chain. I have to deal with the angle between adjacent angles, dihedral angles, and vibration. I am able to compute all three separately: I create an acceleration matrix by computing the forces. The acceleration matrix has rows=dimension and ...
Background & Problem formulation I'm trying to write a simple program in C++ that performs adaptive numerical integration of vector valued integrands (in one variable), i.e. $$\int_a^b \bar{f}(x) \ dx $$ where $\bar{f} = \{f_1, f_2, ..., f_n\}$. I know that there are good libraries that can do this (for example GSL ...
Recently, I am trying to solve 2D Euler Equation using FV-WENO reconstruction. For the smooth initial problem, component-wise WENO reconstruction works well. My problem is, if I want to solve double mach reflection problem, do I need to do characteristic decomposition? It seems that doing characteristic decomposition i...
I have a standard set of linear equations $Ax=b$ where the Hessian matrix $A$ has the special block structure as shown: $A= \begin{pmatrix} T & U\\ U^T & V \end{pmatrix}$, $x= \begin{pmatrix} c\\ d \end{pmatrix}$ Where $A$ is square Hessian matrix and each dimension is of size $n = c_n + d_n$. This compound dimension...
In Single-Photon Emission Computerized Tomography (SPECT) parallel beam reconstruction using Maximum-Likelihood Expectation–Maximization(MLEM), is it sufficient to scan the object around 180 degree? or it is required to perform full 360 scan?
I couldn't find a simple answer to this thing I'm trying to do in Matlab. I have a function file that does some calculation for a given parameter a: []=my_function(...,a) ... Calculations to obtain some functions y_1(x),y_2(x),... for a given parameter a. ... figure(1); plot(x,y_1); title('y_1(x)'); xlabel('x'); ylab...
I'm working in laboratories where molecular dynamics data are almost always analysed usign block average as stated in the famous Allen and Tildesley book. We divide the datas in blocks of size $M$ on which we compute our interesting quantities. We consider that for large enough blocks, the fluctuations converge so: $$ ...
I am trying to write a program to compute the advection equation. $$u_t +u_x = 0$$ I use the spectral method for the spatial derivative $u_x$ and the leapfrog method for the time derivative $u_t$. That will give the an equation for the next time step: $$u_{j}^{k+1} = u_{j}^{k-1} - \frac{\Delta t}{n}[f^{-1}(iN \pi f(U_{...
What is the most efficient and numerically stable algorithm for computing the inverse CDF $F^{-1}(y)$ of a probability function, assuming that both the PDF $f(x)$ and the CDF $F(x)$ are known analytically but the inverse CDF is not? Clearly, this is the same as finding the root of the nonlinear function $G(x) \equiv F(...
A common approach to image reconstruction is to solve the convex optimization problem \begin{equation} \text{minimize} \quad \frac12 \| Ax - b \|^2 + \gamma \| Dx \|_1 \end{equation} where $b$ is a vector of measurements (perhaps a blurry, noisy image), $A$ is a linear transformation that maps the reconstructed image ...