A general purpose high-level programming language that emphasizes ease of code syntax and readability.
7
votes
0answers
104 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 ...
3
votes
1answer
68 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
23 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
27 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
44 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 ...
9
votes
3answers
131 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
98 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 ...
7
votes
1answer
125 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 ...
2
votes
1answer
70 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
86 views
-3
votes
1answer
106 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
11 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?
1
vote
1answer
53 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
59 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
0answers
46 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 ...
-1
votes
0answers
53 views
Pre-stressing within fenics
How can I go about incorporating pre-stressing into a code using fenics. In particular what I have is a code which creates a mesh, applies external forces and calculates the displacement based on min ...
7
votes
3answers
253 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
105 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
105 views
Compute lengths of the longest edge of each cell
Having
mesh = UnitSquareMesh(2, 2)
Q = FunctionSpace(mesh, 'DG', 0)
this works as expected
...
4
votes
1answer
68 views
compute max(||u||) for vector field
Given a vector-valued Dolfin function u from the function space V*V with ...
3
votes
1answer
131 views
plotting a 2D animated data surface on MatPlotLib
I'm trying to get an animated 2D data surface on MatPlotLib. After a bit of search on the internet, i've found an example that almost works:
...
2
votes
0answers
150 views
Newton Iteration method convergence
I wrote a Python code which solves a second degree nonlinear differential equation using the Newton iteration method. The code converges to a 2-cycle within 50 or so iterations. The cycle only ...
8
votes
2answers
186 views
Astoundingly large difference when evaulating trigonometric identity with NumPy
According to Wolfram Alpha and the Sage computer algebra system, the following identity holds:
$$
\cos\left(\arctan\left(\frac{l_1-l_2}{d}\right)\right) = \frac{1}{\sqrt{1 + \frac{(l_1-l_2)^2}{d^2}}}
...
5
votes
1answer
84 views
Package for determining power output of windmill shapes?
I'm looking for the best package for doing the following: building a 3D model (or loading externally) of a non-standard windmill shape, simulating an airflow over the model, and determining the ...
4
votes
2answers
101 views
SciPy interpolation with Univariate Splines
I have coded a routine for interpolation with B-splines, only to discover later that this functionality is already included in Python's SciPy.
However, I do not understand one parameter in the SciPy ...
4
votes
2answers
182 views
F2Py with allocatable and assumed shape arrays
I would like to use f2py with modern Fortran. In particular I'm trying to get the following basic example to work. This is the smallest useful example I could ...
9
votes
1answer
126 views
Why does SciPy eigsh() produce erroneous eigenvalues in case of harmonic oscillator?
I'm developing some larger code to perform eigenvalue computations of huge sparse matrices, in the context of computational physics. I test my routines against the simple harmonic oscillator in one ...
1
vote
2answers
126 views
Solver error in SciPy/LSODA with a very specific parameter set
I'm implementing a very simple Susceptible-Infected-Recovered model with a steady population for an idle side project - normally a pretty trivial task. But I'm running into solver errors using either ...
2
votes
1answer
53 views
python numpy print array(x,y,z) as (x by y) by z?
Printing photo matrices (x,y,z) where z is 0:2 colour, I want to see (x in rows, y in columns) 3 times, once for each colour (the way I've been taught by every mathematician). By default, numpy does ...
7
votes
1answer
209 views
Schroedinger/Diffusion equation with Crank-Nicolson in Python/SciPy
I tried to make the question as detailed as possible. I have an extremely simple solver written for the Schroedinger equation but with imaginary time, which transforms it basically into the diffusion ...
15
votes
0answers
174 views
How does the performance of Python/Numpy array operations scale with increasing array dimensions?
How do Python/Numpy arrays scale with increasing array dimensions?
This is based on some behaviour I noticed while benchmarking Python code for this question: How to express this complicated ...
4
votes
1answer
97 views
TypeError from scipy.optimize.curve_fit
I am trying to fit a data set to an exponential model using scipy. However, the covariance matrix that is returned is 'inf' and I receive the following error:
Traceback (most recent call last):
...
5
votes
2answers
144 views
Rearrange an ordinary matrix to block diagonal form
Is there an algorithm to rearrange a matrix into block diagonal form, given that the matrix is block diagonal in nature but randomized with an unwise choice of basis?
In particular, are there any ...
11
votes
2answers
230 views
How to express this complicated expression using numpy slices
I wish to implement the following expression in Python:
$$
x_i = \sum_{j=1}^{i-1}k_{i-j,j}a_{i-j}a_j,
$$
where $x$ and $y$ are numpy arrays of size $n$, and $k$ is a numpy array of size $n\times n$. ...
8
votes
1answer
206 views
Numerical integration for modelling curve for superconductors (Python)
I am a physicist who is trying to model the current-voltage characteristics of a superconductor-superconductor junction.
The equation for this model is:
\begin{align}
I(V) = ...
3
votes
3answers
105 views
Averaging scattered data
I have multiple sets of measured data that can easily be visualized using a scatter plot (red and black points in the figure). If my measurements were perfect, the red and black points should lie on a ...
2
votes
2answers
124 views
vectorizing a non-trivial function in numpy
I have a 2d numpy array, with shape (100,3)
a = np.random((100,3))
and I want to call a function ...
3
votes
2answers
106 views
Consistent handling of division by zero in numpy array
I want to populate a numpy array with values from the smooth bump function
f(x) = exp ( - 1 / (1 - x^2) ) if |x| < 1, f(x) = 0 otherwise
Currently I ...
8
votes
9answers
421 views
Do I need to learn C?
I am a PhD student in Scientific Computing and over the past few months, I spent a good amount of time learning Python and C++ the right way. I feel that I have learnt C++ well and I can use Python to ...
4
votes
6answers
381 views
Soft Question: Where does Python fit into the picture?
So I've been debating whether or not I should bother learning Python. From speaking with my professors, Matlab seems to be the common language used in applied mathematics/computational science as far ...
9
votes
1answer
230 views
Python OSS alternatives for Matlab Neural Network Toolbox. Any intercomparisons?
I'd like to be independent of commercial software for my scientific work. I find a dependence an commercial packages such as Matlab and its toolboxes unsatisfactory, because I do not know if I will ...
4
votes
1answer
129 views
Find / Detect / Enumerate all Cliques or Independent Sets
What are generally best choices for enumerating all k-cliques (or independent sets of size k)?
The graphs I am looking at probably won't have more than ~ 100 nodes.
Presently I code in Python with ...
6
votes
1answer
128 views
Nonlinear dynamics: algorithm suggest
I've just started a thesis on nonlinear dynamics which entails numerical analysis of the Duffing oscillator (DO). It's basically just a second order ODE, or equivalently a set of ODEs.
Say, after ...
2
votes
1answer
419 views
Logistic regression with Python
I am trying to code up logistic regression in Python using the SciPy fmin_bfgs function, but am running into some issues. I wrote functions for the logistic ...
5
votes
1answer
158 views
Recommendation for a python book for data processing
I've been doing FORTRAN programming for 10 years and I've started using python for a few years now, mostly for data processing. I've been lucky enough to work with people that are knowledgeable ...
2
votes
1answer
87 views
Reshape and Index (State) Products in Numpy
Consider the following:
I start with a $2\times 2$ matrix $W_{ij}$. I then take this $W$ matrix and make a new tensor, $T$, by doing the following:
$$
T_{ijkl}=\sum_{a}W_{ai}W_{aj}W_{ak}W_{al}
$$
...
2
votes
1answer
226 views
fmincg implementation in Python
I'm trying to re-implement Neural Networks in Python. I implemented the cost function and the backpropogation algorithm correctly. I have checked them by executing its Octave equivalent code.
But ...
4
votes
1answer
223 views
Using scipy.optimize to implement a neural network with back propagation
My problem is something similar to this.
I'm trying to implement a (Neural Network) Cost function, Back propogation algorithm in Python.
The Neural Network has 3 layers. Hence 2 parameters to ...
0
votes
0answers
118 views
how to move particles in a variational monte carlo simulation
I'm attempting to implement some code that moves particles and then calculated the acceptance/rejection of the move, but i'm stuck in a rut, here is my python code:
...
8
votes
2answers
453 views
CVXOPT VS. OpenOpt
CVXOPT: http://abel.ee.ucla.edu/cvxopt/index.html
OpenOpt: http://openopt.org/Welcome
What's the relation between them?
What are the advantages/disadvantages of them, respectively?
BTW, is there ...


