Skip to main content
Filter by
Sorted by
Tagged with
2 votes
0 answers
59 views

I'm computing PDE residuals for The_Well datasets (e.g. turbulent_radiative_layer_2D and shear_flow) using finite differences, but the residuals are much larger than I expect. The data are generated ...
Kain's user avatar
  • 21
1 vote
2 answers
125 views

I am new to coding and trying to solve a simple 1D dispersion equation. The equation and boundary conditions: adC/dx = bd^2C/dx^2 x = hj, C = C0; x = - inf, C =0 The analytical solution is C = C0 * ...
user28866182's user avatar
3 votes
1 answer
112 views

Inside the KrylovJacobian class from SciPy, there is this method: def _update_diff_step(self): mx = abs(self.x0).max() mf = abs(self.f0).max() self.omega = self.rdiff * max(1, mx) / max(1, ...
Ultrinik's user avatar
1 vote
1 answer
103 views

In the following OpenMP C code I was expecting that using tempfield could help to write to p1 in one cache line, which in my case is 64 bytes. With two threads I got almost 2x speedup in comparison to ...
Joan Guastalla's user avatar
0 votes
1 answer
328 views

I have to simulate a lid driven cavity flow. The idea is as follows: Initialize boundary conditions Update stream function (using discretized version, update only if the convergence condition is ...
htiduj's user avatar
  • 1
1 vote
0 answers
95 views

I want to solve the following boundary value problem where S, k_i, x_f, α_1, and θ are known parameters. We are trying to solve for h(x), p, and θ_d. My idea was to use finite differences to create a ...
Mjoseph's user avatar
  • 163
1 vote
0 answers
63 views

I am trying to modify a code to include a runge kutta time stepping scheme. The original code was not written by me but my motive is to eliminate the pygame library and make it as easy as possible ...
donet3088's user avatar
1 vote
1 answer
308 views

I want to visualize the solution of the following partial differential equation: u_t=u_xx+u_yy+f(u) At different times, such as u(t=1) and u(t=3). I use a finite difference scheme and the following ...
RIM's user avatar
  • 13
0 votes
1 answer
1k views

Hi I am trying to code a simple advection equation in python using the finite difference upwind method. I have looked online to find a simple example of this but the codes I have found are a little ...
user24293678's user avatar
0 votes
1 answer
116 views

I'm having trouble understanding why this for loop is not working. Full code is also below. I want to calculate the temperature at future time points (j+1) based on the temperatures at the previous ...
curiousmind's user avatar
0 votes
1 answer
60 views

I'm reading the devito_book/fdm-jupyter-book/notebooks/01_vib/vib_undamped.ipynb and the code in it seems not compatible with devito 4.8.3. So I tried to rewrite it as: import numpy as np from devito ...
Shanmu Jin's user avatar
0 votes
0 answers
507 views

For a school project, I am implementing in Python a finite difference method to numerically solve the following system of reaction diffusion PDE: I have so far implemented the following: import numpy ...
cosmic_crafter's user avatar
0 votes
1 answer
128 views

Consider the following code: x = np.array([1, 5, 6, 10]) # an unstructured coordinate f = x**2 # function value on the points x grad1 = np.gradient(f, x) # df/dx ...
pretzlstyle's user avatar
  • 3,042
0 votes
1 answer
371 views

I have a 3D array of data A, with shape (NX, NY, NZ) in the x, y, and z dimensions, respectively. I want to find the gradient of A in the y dimension. This can be done easily with NumPy: dAdy = np....
pretzlstyle's user avatar
  • 3,042
1 vote
0 answers
344 views

Given a diffusion equation: $$\frac{\partial S}{\partial t} = c \Big(\frac{\partial^2 S}{\partial x^2} + \frac{\partial^2 S}{\partial y^2} \Big)$$ with homogeneous Neumann Boundary Condition $$\frac{\...
JEAD MACALISANG's user avatar
1 vote
1 answer
184 views

I want to calculate a discrete approximation of df/dx in Matlab using a vector f representing the function and a Matrix D representing a differential operator. f in this example is a simple sine wave ...
Bulbasaur's user avatar
  • 156
1 vote
0 answers
86 views

I can't figure out why this code is not working: #include <Eigen/Sparse> #include <vector> #include <iostream> #include <Eigen/IterativeLinearSolvers> // u''(x)= 1 // Boundary ...
Eder Lima de Albuquerque's user avatar
0 votes
0 answers
261 views

It's my first time posting here and it seems like latex is not working, so I posted some part as an image. Reference for Relaxation method: Computational Physics by Veseley I have employed the two ...
mathemania's user avatar
1 vote
2 answers
821 views

Say I have vectors x and y and want to calculate the second derivative of y with respect to x using finite differences. I'd do x <- rnorm(2000) y <- x^2 y = y[order(x)] x = sort(x) dydx = diff(...
Anthony Tan's user avatar
0 votes
0 answers
146 views

I am developing a MPI based parallel numerical solver for a Laplace equation subjected to Dirichlet Boundary condition using Finite Difference method.I have taken a square computational domain with a ...
Srinivas Inturu's user avatar
1 vote
1 answer
612 views

I have a function f = dp/de (variation in pressure as a function of variation in energy) and I would like to calculate this derivative with finite differences. I have a list for the p values ​​and a ...
Ramos's user avatar
  • 9
1 vote
0 answers
75 views

I wrote a finite difference algorithm to solve the wave equation which is derived here. When I ran my code, the plotted graphs of the numerical and analytical solution deviated, which is the problem I ...
FriendlyNeighborhoodEngineer's user avatar
1 vote
1 answer
557 views

I have been looking at numerical methods to solve differential equations for chemical reactions. Usually I put the differential equation into a tridiagonal matrix using finite difference method, and ...
simon's user avatar
  • 83
0 votes
1 answer
184 views

I want to solve a differential equation of a given function S. First, I integrate a function using 4th-order runge kutta: def rk4_step(r, u, h, f, *args): k1 = h * f(r, u, *args) k2 = h * f(r +...
User8563's user avatar
  • 375
2 votes
1 answer
411 views

I am trying to numerically solve the Klein-Gordon equation that can be found here. To make sure I solved it correctly, I am comparing it with an analytical solution that can be found on the same link. ...
FriendlyNeighborhoodEngineer's user avatar
1 vote
0 answers
190 views

I am trying to implement a finite difference scheme for KdV equation in MATLAB, and I have most of the code ready, except for approximation at the first level using initial condition. It was suggested ...
dannyt's user avatar
  • 11
1 vote
2 answers
394 views

I am new to Cuda. I am trying to solve the wave equation with the initial condition in the form of the Ricky momentum. The performance of the code is 12 GFlops, although my GPU performance is 3900. ...
homidov's user avatar
  • 11
0 votes
0 answers
89 views

/****************************************************************************** Online C Compiler. Code, Compile, Run and Debug C program online. Write ...
2342's user avatar
  • 1
0 votes
1 answer
535 views

(TLDR: SymPy's linsolve function is unable to solve the system of linear equations, generated from applying the finite difference method to an ODE BVP, when you pass the equations as a pure Python ...
Numerical_Pythonista's user avatar
0 votes
0 answers
270 views

I am trying to solve the 1D ADE This is my code so far: clc; clear; close all %Input parameters Ao = 1; %Initial value L = 0.08; %Column length [m] nx = 40; %spatial gridpoints ...
gary105's user avatar
  • 49
0 votes
1 answer
2k views

I have an (X,Y,Z) numpy array that describes every point inside a box. I would like to do a 3D plot of this data where the colour of the point at [x,y,z] is the value of that point in the array I have ...
Dan Woods's user avatar
0 votes
0 answers
170 views

I understand why this error is occurring. I am using finite differences to find solutions with a numpy array of size n = 400 and the term in question produces a term i + 2 which for i in range(1, n - ...
AlphaArgonian's user avatar
1 vote
0 answers
496 views

Firstly, I would like to mention that I am a complete beginner when it comes to coding, let alone C++, so bear with me, as I need complete guidance. My task is to implement the Lanczos algorithm for ...
Cia's user avatar
  • 11
0 votes
0 answers
590 views

I know that in R diff(x, lag = L, differences = K) gives you the lag-L K-th order forward difference. But it only allows for positive lags, so only can give you the forward differences, not backward ...
Tom Wenseleers's user avatar