Questions tagged [python]
A general purpose high-level programming language that emphasizes ease of code syntax and readability.
65
questions
0
votes
0
answers
37
views
Preconditioner Implementation with matrix-free methods (sparse iterative solvers)
How can I define preconditioners (SPILU,SPAI, etc.) for sparse iterative methods (TFQMR,GMRES,CGS, etc.) for the matrix-free left-hand side? I defined Ax=b using matrix-free A (with LinearOperator and ...
3
votes
1
answer
545
views
Overflows and underflows in Python
I’m writing some Python code using NumPy. Since I got an overflow warning, I decided to check for underflows as well at all places in the code, using ...
1
vote
1
answer
130
views
Coupled Partial Differential Equations
I'm trying to solve the following system of coupled differential equations, the two-temperature model for $e$ = electrons and $l$ = lattice.
$$
\rho_{e}C_{p,e}\frac{\partial T_{e}}{\partial t} = k_{e}\...
0
votes
1
answer
81
views
optimize this python code that involves matrix inversion
So I have this line of code that involves a matrix inversion
X = A @ B @ np.linalg.pinv(S)
$A$ is an $n$ by $n$ matrix, $B$ is an $n$ by $m$ matrix and $S$ is an $...
1
vote
0
answers
11
views
Guidelines for image detection model for statis sample
I have 20,000 plus images of art (paintings, sculptures, jars, etc). My goal is creating a computer vision model that, from an input (image), identifies the exact same piece of art and returns its id, ...
4
votes
1
answer
103
views
How can I efficiently find an anti-symmetric generator of a special orthogonal matrix?
Given a special orthogonal matrix $O$ (i.e: $OO^T = 1$ and $\det(O) = 1$), I am trying to efficiently find a matrix $X$ such that $O = e^X$ and $X = -X^T$ using Python (NumPy & SciPy).
One obvious ...
0
votes
0
answers
20
views
What is the most accurate way of computing the evaluation time of a neural network model?
I am training some neural networks in pytorch to use as an embedded surrogate model. Since I am testing various architectures, I want to compare the accuracy of each one, but I am also interested in ...
2
votes
0
answers
108
views
Coding a performant flexible scientific code with Python
I aim to code a PDE flexible fast PDE solver. I read and noticed multiple approaches:
Python + Numba
Python + Cython
Python + some compiled language (c++/fortran)
The equations to be solved are ...
0
votes
0
answers
33
views
Help needed in generating a list of radii
I am trying to generate a list of radii between two given points (0 and 1 in this example). Below is my code in Python to generate the list.
...
0
votes
0
answers
56
views
Why is Magnetic Susceptibility not showing the expected transition in 2D&3D Ising Model?
I'm trying to code the Ising Model with the metropolis algorithm to study the ferromagnetic-paramagnetic transitions. The code seems to work ; the equilibration happens. While equilibrating, the ...
1
vote
1
answer
61
views
How to constraint the tangential gradient on a boundary in FEniCS?
The problem I'm considering is a 2D scalar PDE.
The domain $\Omega$ is a disk with two holes $\partial\Omega_1$ and $\partial\Omega_2$ and an external boundary $\partial\Omega_0$.
The PDE and boundary ...
1
vote
1
answer
202
views
Numerically solving the Advection-diffusion equation with no-flux boundary condition leads to violation of mass conservation
I am trying to solve numerically the advection-diffusion equation of the following form
$$\frac{\partial C}{\partial t}=\alpha\frac{\partial^2 C}{\partial x^2}+\beta \frac{\partial C}{\partial x}$$
...
0
votes
0
answers
42
views
Find peaks method for finding elusive peaks
I'm currently utilizing the find_peaks function to identify peaks within this spectrum. However, despite consulting similar queries on Stack Overflow, my attempts to incorporate features such as ...
0
votes
0
answers
45
views
How to calculate the numerical integration and plot the result in python?
I am trying to solve the question below in McQuarrie Physical-Chemistry book.
The first step of the exercise, I solved. However, the second step involves a numerical integration. I can develop a code ...
1
vote
0
answers
53
views
Converting an expression into an einsum
I have the following expression that I need to calculate for some matrices:
$$
\sum_{k}c_{t,i,k}\sigma^\prime\left(w_tX_t+b_t\right)_k\left(\sum_\ell w_{t,k,\ell}\tilde{X}_t^{w,\ell}\right)
$$
I could,...