All Questions

48
votes
4answers
6k views

What guidelines should I follow when choosing a sparse linear system solver?

Sparse linear systems turn up with increasing frequency in applications. One has a lot of routines to choose from for solving these systems. At the highest level, there is a watershed between direct (...
64
votes
9answers
11k views

What are some good strategies for improving the serial performance of my code?

I work in computational science, and as a result, I spend a non-trivial amount of my time trying to increase the scientific throughput of many codes, as well as understanding the efficiency of these ...
155
votes
10answers
116k views

Recommendations for a usable, fast C++ matrix library?

Does anyone have recommendations on a usable, fast C++ matrix library? What I mean by usable is the following: Matrix objects have an intuitive interface (ex.: I can use rows and columns while ...
6
votes
1answer
1k views

Computational methods for finding the energy eigenvalues of the time-independent Schrodinger equation with arbitrary potential

I have seen in some papers that the energy levels in some arbitrary potential are specified. How can one find the energy levels in such arbitrary potentials. For example, $V(x)=\sin^2(x/2)$ with $x\in[...
22
votes
2answers
10k views

Why is my iterative linear solver not converging?

What can go wrong when using preconditoned Krylov methods from KSP (PETSc's linear solver package) to solve a sparse linear system such as those obtained by discretizing and linearizing partial ...
24
votes
1answer
4k views

Conservation of a physical quantity when using Neumann boundary conditions applied to the advection-diffusion equation

I don't understand the different behaviour of the advection-diffusion equation when I apply different boundary conditions. My motivation is the simulation of a real physical quantity (particle density)...
15
votes
4answers
1k views

How to reorder variables to produce a banded matrix of minimum bandwidth?

I'm trying to solve a 2D Poisson equation by finite differences. In the process, I obtain a sparse matrix with only $5$ variables in each equation. For example, if the variables were $U$, then the ...
73
votes
6answers
16k views

How much better are Fortran compilers really?

This question is an extension of two discussions that came up recently in the replies to "C++ vs Fortran for HPC". And it is a bit more of a challenge than a question... One of the most often-heard ...
41
votes
18answers
2k views

Where can one obtain good data sets/test problems for testing algorithms/routines?

In evaluating the quality of a piece of software you are about to use (whether it's something you wrote or a canned package) in computational work, it is often a good idea to see how well it works on ...
19
votes
3answers
1k views

Can diagonal plus fixed symmetric linear systems be solved in quadratic time after precomputation?

Is there an $O(n^3+n^2 k)$ method to solve $k$ linear systems of the form $(D_i + A) x_i = b_i$ where $A$ is a fixed SPD matrix and $D_i$ are positive diagonal matrices? For example, if each $D_i$ is ...
15
votes
1answer
3k views

How can I estimate the condition number of a large sparse matrix using PETSc?

I have a PETSc Mat and would like to estimate its condition number.
7
votes
1answer
1k views

full rank update to cholesky decomposition

Let $A$ be a real, symmetric, positive definite matrix. It has at least 500 rows, possibly much more. I compute its Cholesky decomposition, which allows me to calculate $det(A)$ $A^{-1}X$ for some ...
52
votes
7answers
5k views

What core skills should every computational scientist have? [closed]

Every scientist needs to know a bit about statistics: what correlation means, what a confidence interval is, and so on. Similarly, every scientist ought to know a bit about computing: the question is, ...
31
votes
9answers
4k views

Modern resources for learning FEM

I need to get started using Finite Element Methods. I am about to start reading Numerical solutions of partial differential equations by the finite element method by Claes Johnson, but it's dated 1987....
35
votes
6answers
3k views

Are there simple ways to numerically solve the time-dependent Schrödinger equation?

I would like to run some simple simulations of scattering of wavepackets off of simple potentials in one dimension. Are there simple ways to numerically solve the one-dimensional TDSE for a single ...
31
votes
2answers
4k views

Strange oscillation when solving the advection equation by finite-difference with fully closed Neumann boundary conditions (reflection at boundaries)

I am trying to solving the advection equation but have a strange oscillation appearing in the solution when the wave reflects from the boundaries. If anybody has seen this artefact before I would be ...
24
votes
4answers
6k views

How to add large exponential terms reliably without overflow errors?

A very common problem in Markov Chain Monte Carlo involves computing probabilities that are sum of large exponential terms, $ e^{a_1} + e^{a_2} + ... $ where the components of $a$ can range from ...
17
votes
4answers
4k views

The definition of stiff ODE system

Consider an IVP for ODE system $y'=f(x,y)$, $y(x_0)=y_0$. Most commonly this problem is considered stiff when Jacobi matrix $\frac{\partial f}{\partial y}(x_0,y_0)$ has both eigenvalues with very ...
14
votes
2answers
15k views

Writing the Poisson equation finite-difference matrix with Neumann boundary conditions

I am interested in solving the Poisson equation using the finite-difference approach. I would like to better understand how to write the matrix equation with Neumann boundary conditions. Would someone ...
6
votes
1answer
277 views

Guidelines for choosing manufactured solutions for numerical PDE schemes

When testing a numerical method for a PDE, I know that it's often useful to compare it to a known analytical solution. If none is available, one can always 'manufacture' a solution, substitute it ...
5
votes
1answer
705 views

Meshing options to generate number of the sides of and element (tetgen-triangle)

I wrote a finite element code in fortran 90. This code is really fast, except the meshing process. I used triangle and tetgen for meshing in 2D and 3D, respectively, so this process is fast, of ...
52
votes
12answers
30k views

C++ vs Fortran for HPC

In my computational science PhD program, we are working almost exclusively in C++ and Fortran. It seems like some professors prefer one over the other. I am wondering which one is 'better' or if one ...
29
votes
3answers
13k views

How to choose a method for solving linear equations

To my knowledge, there are 4 ways to solving a system of linear equations (correct me if there are more): If the system matrix is a full-rank square matrix, you can use Cramer’s Rule; Compute the ...
15
votes
1answer
4k views

What is the general idea of Nitsche's method in numerical analysis?

I know that the Nitsche's method is a very attractive methods since it allows to take into account Dirichlet type boundary conditions or contact with friction boundary conditions in a weak way without ...
42
votes
7answers
4k views

Is algorithmic analysis by flop-counting obsolete?

In my numerical analysis courses, I learned to analyze the efficiency of algorithms by counting the number of floating-point operations (flops) they require, relative to the size of the problem. For ...
7
votes
2answers
3k views

Which Runge-Kutta method is more accurate: Dormand-Prince or Cash-Karp?

I simply want to know whether the Dormand-Prince Numerical Method or the Cash-Karp Numerical Method is more accurate.
22
votes
2answers
2k views

What simple methods are there for adaptively sampling a 2D function?

I have a two-dimensional function $f(x,y)$ whose values I would like to sample. The function is very expensive to compute and it has a complex shape, so I need to find a way to get the most ...
20
votes
9answers
33k views

Basic explanation of shape function

I just started studying FEM in a more structured basis compared to what I used to do during my undergraduate courses. I am doing this because, despite the fact that I can use the "FEM" in commercial (...
25
votes
4answers
8k views

Method for numerical integration of difficult oscillatory integral

I need to numerically evaluate the integral below: $$\int_0^\infty \mathrm{sinc}'(xr) r \sqrt{E(r)} dr$$ where $E(r) = r^4 (\lambda\sqrt{\kappa^2+r^2})^{-\nu-5/2} K_{-\nu-5/2}(\lambda\sqrt{\kappa^2+...
14
votes
3answers
718 views

What is a scalable preconditioner for high-frequency Helmholtz?

Standard multigrid and domain decomposition methods do not work, but I have large 3D problems and direct solvers are not an option. What methods should I try? How are my choices affected by the ...
8
votes
2answers
4k views

How to properly apply non-homogeneous Dirichlet boundary conditions with FEM?

In general, Dirichlet boundary conditions won't be satisfied exactly for FEM for non-homogeneous boundary conditions. The FEM codes I've seen set the degrees of freedom to interpolate the Dirichlet ...
6
votes
2answers
3k views

Poisson equation finite-difference with pure Neumann boundary conditions

I'm trying to solve a 1D Poisson equation with pure Neumann boundary conditions. I've found many discussions of this problem, e.g. 1) Poisson equation with Neumann boundary conditions 2) Writing the ...
5
votes
2answers
447 views

What heuristics can be used to minimize the asymptotic matrix bandwidth of a 5-point Laplacian discretization?

I can see that there are multiple heuristics to achieve a matrix with minimum bandwidth. As heuristics, they can't guarantee an optimal solution in polynomial time (after all, the problem is NP-...
89
votes
14answers
8k views

Is it worthwhile to write unit tests for scientific research codes?

I am strongly convinced of the value of using tests that verify a complete program (e.g. convergence tests), including an automated set of regression tests. After reading some programming books, I've ...
45
votes
5answers
7k views

What are criteria to choose between finite-differences and finite-elements

I am used to thinking of finite-differences as a special case of finite-elements, on a very constrained grid. So what are the conditions on how to choose between Finite Difference Method (FDM) and ...
26
votes
2answers
4k views

Is Crank-Nicolson a stable discretization scheme for Reaction-Diffusion-Advection (convection) equation?

I am not very familiar with the common discretization schemes for PDEs. I know that Crank-Nicolson is popular scheme for discretizing the diffusion equation. Is also a good choice for the advection ...
24
votes
4answers
15k views

Dealing with the inverse of a positive definite symmetric (covariance) matrix?

In statistics and its various applications, we often calculate the covariance matrix, which is positive definite (in the cases considered) and symmetric, for various uses. Sometimes, we need the ...
21
votes
2answers
8k views

Libraries for solving sparse linear systems

There are a number of different libraries out there that solve a sparse linear system of equations, however I'm finding it difficult to figure out what the differences are. As far as I can tell there ...
22
votes
2answers
3k views

A good finite difference for the continuity equation

What would be a good finite difference discretization for the following equation: $\frac{\partial \rho}{\partial t} + \nabla \cdot \left(\rho u\right)=0$? We can take the 1D case: $\frac{\partial \...
21
votes
8answers
2k views

Software package for constrained optimization?

I am looking to solve a constrained optimization problem where I know the bounds on some of the variables (specifically a boxed constraint). $$ \arg \min_u f(u,x) $$ subject to $$ c(u,x) = 0 $$ $$ ...
8
votes
1answer
10k views

How to discretize the advection equation using the Crank-Nicolson method?

The advection equation needs to be discretized in order to be used for the Crank-Nicolson method. Can someone show me how to do that?
22
votes
3answers
3k views

What is the purpose of using integration by parts in deriving a weak form for FEM discretization?

When going from the strong form of a PDE to the FEM form it seems one should always do this by first stating the variational form. To do this you multiply the strong form by an element in some (...
18
votes
4answers
3k views

Is there a general-purpose library for structured grid adaptive mesh refinement?

Adaptive mesh refinement (AMR) is a common technique for dealing with the problem of widely varying spatial scales in the numerical solution of PDEs. What general-purpose libraries exist for AMR on ...
16
votes
4answers
7k views

Profiling CFD code with Callgrind

I'm using Valgrind + Callgrind to profile a solver I have written. As the Valgrind user manual states, I've compiled my code with the debugging options for the compiler: "Without debugging info, ...
12
votes
2answers
2k views

Newton-based methods in optimization vs. solving systems of nonlinear equations

I asked for clarification about a recent question about minpack, and got the following comment: Any system of equations is equivalent to an optimization problem, which is why Newton-based methods ...
22
votes
3answers
3k views

What's the state-of-the-art in highly oscillatory integral computation?

What's the state-of-the-art in the approximation of highly oscillatory integrals in both one dimension and higher dimensions to arbitrary precision?
7
votes
5answers
703 views

Motivation behind Galerkin method

I have a question about Galerkin method. I don't understand why the Galerkin method weights the residual by the shape functions and sets it equal to zero. I want to know what is reason of this. Why we ...
10
votes
1answer
5k views

Are there any heuristics for optimizing the successive over-relaxation (SOR) method?

As I understand it, successive over relaxation works by choosing a parameter $0\leq\omega\leq2$ and using a linear combination of a (quasi) Gauss-Seidel iteration and the value at the previous ...
6
votes
3answers
628 views

Computing accurate fluxes with FEM

I have solved Poisson equation on a 3d domain with neumann and dirichlet boundary condition. I get the potential, take the gradient for each element and integrate on a surface of an element, I do this ...
14
votes
1answer
9k views

How should boundary conditions be applied when using finite-volume method?

Following from my previous question I am trying to apply boundary conditions to this non-uniform finite volume mesh, I would like to apply a Robin type boundary condition to the l.h.s. of the domain (...

15 30 50 per page