Skip to main content

All Questions

3 votes
5 answers
1k views

How do I speed up this simulation program

This is a program to solve a differential equation numerically using Euler method. As of now, it is very slow, and I need to run 10000 Monte Carlo simulations. The differential equation is called ...
Jonathan Wick's user avatar
6 votes
2 answers
482 views

Means square displacement (MSD)

I have written a code to calculate the MSD of some molecules. The code averages over multiple time origins (sliding time window) and over all the molecules. I have also made it do one extra thing: do ...
mjksho's user avatar
  • 61
10 votes
1 answer
329 views

From Hummingbirds to Ornithopters: Simulating the Aerodynamics of Flapping Wings

Ptera Software A Flapping Wing Aerodynamics Simulator Written in Python Motivation About a year ago, I became fascinated by how animals fly. As an aerospace engineering student, it surprised me that ...
wingedNorthropi's user avatar
3 votes
1 answer
352 views

Particle simulator using Python - Why is the NumPy version slower than pure Python?

This is an interesting example from G.Lanaro's book, Python High Performance. The program is a simple simulator which describes movement of particles based on their positions and angular velocities (<...
Omid's user avatar
  • 159
8 votes
2 answers
1k views

Schelling's model of Segregation Python implementation with Geopandas (Follow-up)

This is the repost of the following question as suggested by @HoboProber . Again, if you don't know what is Schelling's model of segregation, you can read it here. The Schelling model of ...
Kartikeya Sharma's user avatar
13 votes
1 answer
337 views

Population dynamic simulation on biological information maintenance 2

This question is the follow-up to this previous question. Background Using this simulation I investigate a system in which enzymes proliferate in cells. During the replications of enzymes, ...
rokamama's user avatar
  • 325
9 votes
1 answer
202 views

Population dynamic simulation on biological information maintenance

Background Using this simulation I investigate a system in which enzymes proliferate in cells. During the replications of enzymes, parasites can come to be due to mutation. They can drive the system ...
rokamama's user avatar
  • 325
1 vote
1 answer
183 views

k-armed bandit problem in Python

I implemented k-armed bandit problem in C#, MATLAB and Python. C# and Matlab code run fairly fast (With same settings of T = 2000 and nRun = 1000 the elapsed time is about 6sec). However, the Python ...
Omid's user avatar
  • 159
7 votes
1 answer
3k views

4-Bar Mechanism Generation

For a school project, I will design and prototype a bicycle brake that uses a four-bar linkage to accomplish its goal. My Python 3 code does this mechanism generation, and implements methods to ...
syb0rg's user avatar
  • 21.8k
2 votes
0 answers
123 views

Sorting overlapping shells in dynamical simulation - for loops vs array methods

I didn't know whether it was best to start with the general task I'm trying to solve, or the meat of the programming problem. They're both below but the former is rather long and solving the latter ...
zephyr's user avatar
  • 143
5 votes
2 answers
312 views

Attempting to run multiple simulations of the Gillespie algorithm for a set of stochastic chemical reactions in less than 10 minutes

I have written Python code that generates a plot. In the code below, when I set maxtime = 0.1, the program takes ~50s and when I set ...
abscissa's user avatar
3 votes
2 answers
565 views

Computation of population patterns in simple agent-based model

I've modeled the population changes for a group of agents that inhabit a 2D lattice (with wrapped boundaries) made up of M x M number of grids. At each time step: ...
neither-nor's user avatar
7 votes
2 answers
299 views

Taking wind data and simulating future wind profiles

I am new to programming, and am using Python to take wind data and simulate future wind profiles. The code as written takes a while to execute and I was hoping someone could suggest ways to make my ...
andrewrmunro's user avatar
3 votes
2 answers
611 views

How can I make my ant simulation faster?

I was not sure if I should post about 200 lines here. I want to make this ant simulation faster. The bottleneck is at Ant.checkdistancebetweenantsandfood(). It ...
kame's user avatar
  • 183