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

learn more… | top users | synonyms

0
votes
0answers
14 views

Finding eigenvalues of a Hermitian matrix using “eigsh” function from scipy

I am trying to use the scipy.linalg.sparse.eigsh function of scipy to find eigevalues of a Hermitian matrix. In the link below it says that eigsh can handle Hermitian matrices but when I run it gives ...
3
votes
1answer
40 views

Finding the minimum hamming distance between a bit vector and any pairwise intersection of multiple bit vectors

I'm looking for a way to optimize this procedure. This is the problem: I have a list of bit vectors $\mathbf{A} = [ a_1, a_2, a_3, ..., a_n ]$ I have a list of bit vectors $\mathbf{B} = [ b_1, b_2, ...
2
votes
1answer
68 views

Adaptive ODE algorithm in Python

I want to integrate a particle path in 2D using the integrate.ode module. Things that are a bit different in my case are that, I only want to integrate up to a ...
2
votes
1answer
30 views

Installing GPAW (Python DFT package) on a computing cluster

I'm in the middle of installing GPAW on a cluster but I'm running into problems building the "gpaw-python" interpreter, its job is to allow users to execute parallelised GPAW calculations. Following ...
3
votes
2answers
96 views

Finding eigenvalues of a complex symmetric tridiagonal matrix

I am trying to find specific eigenvalues and -vectors of a large complex symmetric tridiagonal matrix (at least 10000x10000, and ideally larger). I know roughly which eigenvalues I am looking for, so ...
3
votes
1answer
58 views

spectral decomposition in Numpy, sign difference

I am trying to follow along with an example from a book, but I get seemingly different answers depending on which spectral decomposition function I use in Numpy. I am trying to transform the Matrix G, ...
0
votes
0answers
37 views

Solving a non linear equation and iterating for various values in python

problem:Unable to solve a unknown for multiple known values in a non-linear equation ...
7
votes
3answers
285 views

Computational Physics: Python VS C/C++

Going to teach students of undergraduate level a course titled Introduction to Computer Programming. I am confused a bit. In Computational Physics scientists use C/C++ or Python or Fortran,CUDA ...
1
vote
0answers
64 views

BFGS Fails to Converge

The model I'm working on is a multinomial logit choice model. It's a very specific dataset so other existing MNLogit libraries don't fit with my data. So basically, it's a very complex function ...
5
votes
2answers
114 views

Pandas limitations and its alternatives in Python

I read somewhere that Pandas was first developed for the financial world, at least not especially for natural sciences (physics, biology and so on), so is there any similar data analysis Python ...
2
votes
2answers
60 views

Implement the Huffman code in Python or Numpy?

The Huffman code is a way of compressing data streams by encoding the more frequent items with shorter words. Here is a distribution on the letters A thru J and the code I obtained: ...
2
votes
1answer
69 views

Tikhonov regularization in the non-negative least square [duplicate]

I am working on a project that I need to add a regularization into the NNLS algorithm. Is there a way to add the Tikhonov regularization into the NNLS implementation of scipy [1]? [2] talks about it, ...
2
votes
1answer
105 views

Python: Grid with step control ODE solver

I have a problem in physics formulated via an ODE. Now I like to solve it numerically using Pythons scipy.integrate and the therein complex_ode. I figured out how and it works but now I like to ...
1
vote
2answers
107 views

How to plot orbit of binary star and calculate its orbital elements?

I have a set of dates, position angles ($\theta$) and angular separations ($\rho$) for visual binary star. For example: ...
10
votes
1answer
242 views

When is Newton-Krylov not an appropriate solver?

Recently I have been comparing different non-linear solvers from scipy and was particularly impressed with the Newton-Krylov example in the Scipy Cookbook in which they solve a second order ...
0
votes
1answer
107 views

Successive over-relaxation not converging (when not done in-place)

I'm trying to find the potential given some boundary conditions using the successive over-relaxation method. I have 2 solutions: -One iterates over all elements and applies the formula ...
0
votes
0answers
31 views

bivariate spline class

Ken, Thanks for the answer on bivariate spline class at stackexchange, it helped me. I am newly in python, currently need to do a 2D interpolation. I used interpolate.interp2d from scipy, but I think ...
2
votes
3answers
149 views

Caculating the mean of vector accurately

I am having trouble with calculating a mean of vector with sufficient accuracy. My current solution which works but it quite slow and has unpredictable performance: mean_sum = mean = ...
1
vote
1answer
124 views

Using multiprocessing to assign values to a numpy array [closed]

I have a code similar to this: ...
5
votes
2answers
220 views

How to compute the wavelet approximation of a function?

For the function $f(x)=x$, how to compute the wavelet approximation using Haar basis? I'm new to wavelet, I'm looking for a package which will do something like this ...
1
vote
1answer
204 views

Newton's method in interpolation

I've seen that in Newton's method for interpolating polynomials, the coefficients can be found algorithmically using (in Python-ish): ...
4
votes
2answers
228 views

Big matrix multiplication on single machine

For example I have 2 matrices that can't fit in RAM. I need algorithm or library which can handle this.Preferably Matlab or Python. I think it can be some block matrix multiplication? Also I think ...
5
votes
0answers
135 views

Negative viscosity stabilized by fourth order terms

I am trying to solve a "Navier-Stokes"-type problem where the viscosity is negative. Of course this renders the equation unstable and thus I add a fourth order term, so the entire equation becomes: ...
5
votes
1answer
439 views

Python scripting in Paraview

I've been using the basic visualization features of Paraview. Now, I want to go further by writing python macros to handle some specific tasks. My question for the advanced users: Are there any ...
1
vote
0answers
52 views

Environment for implementing/testing Computer Graphics algorithms [closed]

I need to code up a computer graphics algorithm for Surface Registration. Briefly surface registration is the process of finding "optimal" one-one correspondence between surfaces, where the meaning ...
4
votes
1answer
365 views

Analytic solution 2D scalar wave equation in cylindrical coordinates numerical implementation

I am trying to compare my finite difference's solution of the scalar (or simple acoustic) wave equation with an analytic solution. For that purpose I am using the following analytic solution ...
5
votes
2answers
217 views

Hashing algorithms/implementations for Monte Carlo simulation

To summarise this question in advance, I'm looking for a good hash function that is suitable for generating pseudo-random numbers in Monte Carlo simulations. This means it should be reasonably fast ...
4
votes
1answer
111 views

Basic questions regarding slepc4py/petsc4py

I am brand new to slepc4py and petsc4py (and SLEPc and PETSc in general), and I have a few basic questions. I apologize if these have been answered somewhere - I've looked around for a while and ...
7
votes
2answers
175 views

Minimum path on known potential surface

I'm searching for the minimum path between the minima of a potential surface that is already known on a grid. (source: http://www.math.nus.edu.sg/~matrw/string/) Any point on the path is at an ...
2
votes
2answers
301 views

debugging a rotation matrix for elastic constants

So the problem is that I have a transformation matrix which takes in the elastic constants from the local rtl coordinates and then converts the elastic constants to the global xyz coordinates via a ...
-1
votes
1answer
187 views

defining subdomains in FEniCS (Python) using obtained (solved) variable [closed]

I'd very much appreciate if you could help me out with this as I think I'm missing something simple out or should be using alternate syntax: I am running the following Python code in FEniCS, where I ...
9
votes
2answers
233 views

Data structures for finite volume code: Arrays vs Classes

I have to write a finite volume code for Magnetohydrodynamics (MHD). I have written numerical code before but not at this scale. I just wanted to ask which will be a good choice, using a data ...
13
votes
1answer
329 views

Scientific computing with Python with modern GPUs with double precision

Has anyone here used double precision scientific computing with new generation (e.g. K20) GPUs through Python? I know that this technology is rapidly evolving, but what is the best way to do this ...
9
votes
4answers
379 views

Memory efficient implementations of partial Singular Value Decompositions (SVD)

For model reduction, I want to compute the left singular vectors associated to the - say 20 - largest singular values of a matrix $A \in \mathbb R^{N,k}$, where $N\approx 10^6$ and $k\approx 10^3$. ...
0
votes
0answers
40 views

Calculating a confidence value for a posterior statistic

It may be that I'm using "confidence" here in a technically invalid sense, but please bear with me, and feel free to correct my terminology with something more acceptable. I have prior distribution ...
0
votes
0answers
31 views

Data to test optimization algorithms [duplicate]

I plan to implement some optimization algorithms in Python, say to follow the sequence here or here. What would be a systematic approach to testing the algorithms I write, using either well-known ...
5
votes
1answer
118 views

Calculate large and small frequency separation for the Sun

I want to determine the big and small frequency seperation from timeseries data for the sun. An excerpt of the data (timeseries and power series) is plotted below. The power series is calculated in ...
10
votes
3answers
885 views

Meshing 3D surface data in python

I have a dataset of 3-dimensional points for which I'd like to construct a mesh, using python. All the software I've seen requires that you provide the edges. Is there a program in python which takes ...
2
votes
1answer
647 views

FEniCS: how to specify boundary conditions on a circle inside 2D mesh

I would like to numerically find a mutual capacitance of two stripes of metal on the opposites sides of a cylinder. The problem is obviously a 2D Laplace equation. I would like to find the potential ...
8
votes
1answer
706 views

What is the fastest way to compute all eigenvalues of a very big and sparse adjacency matrix in python?

I'm trying to figure out if there is a faster way to compute all the eigenvalues and eigenvectors of a very big and sparse adjacency matrix than using scipy.sparse.linalg.eigsh As far as I know, this ...
4
votes
1answer
218 views

FEniCS: how to access coordinates when writing an equation for a trial function

I need to solve the following equation in FEniCS: $$ \boldsymbol{\nabla} \cdot \begin{pmatrix} (1+\alpha^2y^2)\frac{\partial u}{\partial x} - xy\alpha^2\frac{\partial u}{\partial y} \\ - ...
2
votes
4answers
143 views

2d-mini element-can't use sub(0),but bubble element is ok

My program (in Python, using FEniCS): ...
-3
votes
1answer
223 views

Fenics : boundary condition

`I am working on a problem found here " http://www.caesarsystems.co.uk/NAFEMS_benchmarks/le10.html" ..I am really confused about the boundary conditions and tried my level best to compute it but ...
1
vote
0answers
18 views

How do I implement a custom kernel in scikit GP?

http://scikit-learn.org/0.13/modules/gaussian_process.html#correlation-models I'd like to write a kernel. How can I do that?
2
votes
1answer
195 views

Fenics : Elementwise stress computation

In a elastodynamics problem, I define the stress as def sigma(v): return 2.0*mu*sym(grad(v)) + lmbda*tr(sym(grad(v)))*Identity(v.cell().d) I have computed ...
0
votes
1answer
123 views

Fenics : looking forward to compute displacements at nodes

I just went through the Fenics book to get the nodal displacements and tried this code .... ...
2
votes
1answer
141 views

Explicit 4th order space wave equation not stable implementation?

The explicit 4th order discretization for the 2D scalar wave equation is given by: \begin{eqnarray} U_{jk}^{n+1} = \left( \frac{\Delta t V_{jk} }{\Delta s} \right) ^2 \left( \sum_{a=-N}^N w_a ...
9
votes
3answers
752 views

Poisson equation: Impose full gradient as boundary condition via Lagrange multipliers

I have a physical problem governed by the Poisson equation in two dimensions $$ -\nabla^2 u = f(x,y), \; in \; \Omega $$ I have measurements of the two gradient components $\partial{u}/\partial{x}$ ...
4
votes
1answer
430 views

Fenics, initialize vector of degrees of freedom for function

With the move away from launchpad I hope this is the right place for this question. Is there a way to initialize the DOFs for a function? generated by u = Function(V) When I run a code which ...
3
votes
1answer
174 views

Compute lengths of the longest edge of each cell

Having mesh = UnitSquareMesh(2, 2) Q = FunctionSpace(mesh, 'DG', 0) this works as expected ...