Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Thursday, May 16, 2013

Extending Radial Distributions

Radial distribution functions are one of the most important quantities to calculate when running a molecular dynamics simulation. They give good insight into the phase and pair potentials between molecules. Practically, they are calculated according to the following equation:

Tuesday, April 30, 2013

Cube-Sphere Intersection Volume

This week's math problem was particularly difficult. I wanted to know the intersection volume between a cube and a sphere. Imagine a sphere contained in a cube. The sphere will first touch the cube when its radius is equal to half the width of the cube. Until that point, its volume is just the formula for the volume of a sphere. Once the sphere's radius is 2 sqrt(3) times the width of the cube, then it completely engulfs the cube and the intersection of the 2 objects is just the volume of a cube. In between, I've found it looks like this:


Wednesday, April 24, 2013

Generating n-Dimensional Lattice Coordinates

It comes up sometimes in my research that I need to generate coordinates along a lattice. For example, when generating an initial structure for a molecular dynamics simulation. I thought I share my code for this. The code works by recursively enumerating each dimension in a lattice and calling a given function each time it reaches a point. So, it could be used to execute any function along a lattice. Here's what it looks like for a 2D and 3D example. In the 3D example I didn't choose a cubic number of points on the lattice, so that it sort of stops in the middle.



Friday, April 12, 2013

Approximate Restricted Integer Partition With Exact Part Number

I'm interested in a certain type of mathematical structure this week: integer partitions. An integer partition, p(n), is the set of sets of integers that add up to n. For example,

  • p(3) = 1 + 1 + 1, 1 + 2, 3
  • p(4) = 1 + 1 + 1 + 1, 1 + 1 + 2, 2 + 2, ...

Saturday, December 29, 2012

Recovering Android Photos with Linux

As noticed by others on the Internet, it is possible to recover photos from an Android phone that were deleted. It is impossible, as far as I know, to recover the full resolution photos. You may, however, recover the thumbnails and those are often large. This also allows you to recover photos which weren't saved, like those from text messages. The problem though is that methods I found while googling require you to edit the image files in a hex editor. For example, as demonstrated in this video. I've instead written a python script which automates this greatly simplifying the fact that you need to recover all the pictures to find one in particular.


Thursday, July 14, 2011

Predator-Prey Models and Global Warming Followup

I thought I'd follow up my last post with some information on some of the tools I used. I'm not going to talk about how I made the equations, because they came out terrible and I'm trying to come up with a new way. I guess if anyone is curious: I made them in LaTeX and used gimp to convert them to PNGs.

Ok, so let's see how I made the graphics. Here's the first graphic, in case anyone forgot.