# Questions tagged [python]

A general purpose high-level programming language that emphasizes ease of code syntax and readability.

824 questions
Filter by
Sorted by
Tagged with
62 views

### Spurious oscillations in solving diffusion problems using finite elements

I've been struggling with this problem for a while so I hope someone can help me here. I'm trying to solve the McNabb-Foster equations for hydrogen diffusion in metals using a simple 1D finite element ...
• 21
29 views

### Passing additional arguments to odeint from torchdiffeq to solve an IVP

In Python I use the package torchdiffeq (as provided here) to solve initial value problems. Given an arbitrary function ...
17 views

### Obtain the flow, knowing the force density

I am working on a python code to reconstruct the 2d flow, knowing the continuous force density applied on the fluid (by deritative of the strain tensor), which as the form of the derivative a ...
• 1
121 views

31 views

### 'None' appears in the end of an outcome. Why? (Python 3.10 64-bit) [closed]

#Here's my code: ...
99 views

### Results of matrix multiplication were very different in MATLAB and Python(Numpy). Why?

I am translating some Matlab code into Python and I having some problems regarding matrix multiplication accuracy.I've compared some intermediate values in my code and I found that the results of ...
1 vote
69 views

### Fitting a rectangle-function to a signal in Python

I have a measured signal (current of a motor, turning on and off again) to which I want to fit a rectangular function in python. I came up with a reasonable ...
• 121
1 vote
54 views

### How to find an alignment between two overlapping time series?

Context I'm working with absorbance spectral data. I have two spectra generated for a single analyte. Each spectrum was collected over two overlapping wavelength regions e.g. 8-10 micron and 9-11 ...
1 vote
92 views

### Error in implementation of Crank-Nicolson method applied to 1D TDSE?

Some context, I've posted this question on physics SE and stack overflow. The former had nothing to offer, the latter had a great commenter that agreed with the phase looking off being one of the ...
85 views

### Is there something unique you can get out of a set of numbers?

I am currently trying to solve a problem with constraint programming. My problem is that for example you need a set of numbers and you can only have a maximum number of 9 with a required length of 6 ...
• 143
1 vote
98 views

### Magnetic field simulation for "quasi-solenoid" - Where to start?

I would kindly ask you which (preferably free) programs / codes do you suggest for the numerical simulation of the problem described below. I am not asking for the full solution, but just want to ...
• 11
1 vote
60 views

### Inaccurate results of integration using scipy solve_ivp

I am trying to use solve_ivp to solve the following 1st order ODE: $$\frac{d \rho}{d z} = \frac{m \theta}{(1+\theta z)} \, \rho,$$ subject to $\rho(z=0)=1$, where ...
• 13
93 views

### Solving nonlinear PDE in Python with LSODA

I am attempting to solve a nonlinear diffusion equation of the form $\partial_t u = \partial_x (\kappa(u) \partial_x u)$, where the conductivity function $\kappa(u)$ is a power law $\kappa = u^{5/2}$, ...
• 2,138
89 views

1 vote
368 views

### CFD in Python: Mesh Generation

I am trying to set up a 3D CFD scheme for thermal and flow modelling in Python using the finite volume method. The first concern is to build the geometry and an accompanying mesh that is efficient for ...
165 views

110 views

### Numerical instability in the inverse Laplace transform

I have a problem with Laplace inversion and my function is not numerically stable for the Laplace inverse, but I do not understand the cause of this problem. Here is my code and graph of this problem. ...
53 views

### Examples of kinetic modeling with optimization techniques in Python

We are looking for studies or tools that implemented kinetic modeling with parameter estimation differential evolution or similar optimization techniques in Python. We are trying to understand what ...
29 views

### How can I couple MCNP with FLUKA? To attain reactor dynamics and simulate an ADS experiment? (Under Subcritical fast system)

I'm new in Particle Physics based Computing. I want to simulate an ADS experiment (Accelerator Driven System) in subcritical fast system. I was advised to simulate the experiment with FLUKA with MCNP ...
132 views

### How to deal with solving coupled ODE systems where variables are updated multiple times within each timestep?

I'm solving a system of coupled ODEs using Euler integration for simplicity. To make this concrete, please see the (extremely simplified) minimal working example below in Python. Imagine we have a box ...
• 193
56 views

### Help Finding Roots

I need to refine a level curve representing an implicit function that is not numerically solvable in sympy. The initial solution set generated by matplotlib's ...
• 143
234 views

### Rotate a 2D contour plot through 360 degrees to create 3D plot (Python, Mayavi/Matplotlib)

I have three 1D arrays, which represent radius, height, and an intensity measured at that point. I have plotted these to create a 2D contour map. A simple example of the way in which the data is ...
• 41
1 vote
83 views

### Help with CVXPY and Disciplined Convex Programming

I'm trying to recreate Figure 1 in this paper. This requires maximizing equation (19), which I have convinced myself is concave, but I am having trouble implementing it in CVXPY. Here is the code I ...
52 views

### Oscillating eigenvectors for 2d-laplace operator

I am trying to calculate the eigenvectors of a Laplace-operator in 2d, with boundary conditions equal to $u=0$ if $x, y$ are outside of a rectangle defined as $(0.5, 0.5), (1.5, 1.5)$. For that I used ...
• 543