More Machine Learning Experiments

This time, I trained GPT-2 on Shakespeare’s sonnets. Some of the results are fairly convincing, though still strange, and the algorithm was obviously very confused by the punctuation, throwing colons and semi-colons around where it pleased.

I love thee, and want thee more;
Be thou mine only object; then may
All other things be thy treasure, and all
Thy love may be more fully expressed.
Make thee still my object, and I thy ward:
And so may I content myself,
Till all my want be amissed of thee.

But do not think on that time when I fly
To new-formed change for new-formed change,
For still my hand is in thee, still doth lend,
And to all whom thou wilt send I yield thee,
That thy part in life may be known,
And all nations may hear of my deeds:
Yet think on this; if thou shouldst turn from me,
The very spot whereon I fleed beginneth
To plant new love in me again;
Thus, being but once in all, time doth waste
Every instant that it possesses,
Lifting everything that lies in rest.
My love is like thy beauty to show,
And thy love is like the making of me.

Were I but blind, I should be mad
To see that sweet favour fall from the heaven,
Which sweet favour doth help my blind world make,
From that sweet favour come times that are far,
And so live in everlasting wax that neither eye
Nor hair can see in them- selves that are hence.
O Fate! if thou wilt aid me, do so now;
The whole world revolves round about me,
Which in turn upon their parts is made,
That they mine inward-and-forth I serve.
O Fate! grant not that I was slain,
To see your holy name fade from heaven.

Posted in Uncategorized


Suppose you had a circle made of a hundred or so equidistant points on its circumference. If you drew straight lines connecting distant points on this circle (chords) in some systematic way, you’d produce a kind of spirograph. I don’t know what these plots are actually called, and “spirograph” is actually just the brand-name of a popular toy, but in any case, most people have probably drawn something like this at some point in their lives.

The most common form of these that I’ve encountered are ones where the pattern for connecting the points is to simply connect every point p_i to p_{i+k} where k is some fixed offset. What if instead we connected p_i to p_{ik} where k is now a fixed multiplier?

I used the Desmos graphing calculator to play around with different values of k in real time. I did not expect the “lobe” count to scale as \propto k-1.

I wonder if someone could come up with some hand-wavy argument as to why this behaves this way? In any case, you can try it out at Desmos here.

Posted in Uncategorized

Simple Monte Carlo Radiation

I tried my hand at writing a simple Monte Carlo radiation transport code a couple of nights ago. It turned out not to be very difficult to write, and at only 50 lines of code, it produces some pretty amazing results:

This image represents the deposition of photon energy into a liquid drop suspended in a gas-fill container. The bright spot above and to the left of the droplet is the photon source.

Posted in Research

A Chinese Room Writes a Sequel to Blindsight

For anyone who has read Blindsight (by Peter Watts), you’ll know that the concept of a Chinese Room plays a major part in the premise. For the sake of irony, I trained an AI I’ve been playing with to write a passable sequel to Blindsight.

Continue reading

Posted in Uncategorized

Packing Boulders

Screen Shot 2017-02-08 at 3.48.58 PMI’ve had some ideas kicking around my head regarding how to efficiently pack objects of various sizes into a volume. I decided to finally try writing an algorithm that would randomly insert objects picked from a size distribution profile, and then apply repulsion forces between them to “pack” them into a low-energy state. This is the basic principle behind a gravitational glass algorithm, but I’m hoping I can take this a step further and now use these positions as seeds for a voronoi, and then “erode” the fully connected voronoi diagram into something like a bunch of packed boulders.

Posted in Research

RPRPS Generator

There is a huge library of work on the subject of sphere packing, some of which is very relevant to SPH, most of which is not (mainly because SPH particles are not hard spheres), and the state of the art for spherical particle arrangements in SPH at the moment is some combination of random seeding with an inverse gravity-like force to push the particles into an optimal arrangement. I’ve used this approach myself many times in the past, relying on the WVT algorithm developed at LANL, but it’s computationally expensive, and it isn’t the sort of thing you can fiddle with at run-time to add more resolution if you need to.

So, a little while back I developed a new algorithm that I call the RPRPS generator. RPR stands for recursive primitive refinement, and PS means parameterized spiraling. The algorithm is pretty clever:

For the center region of the sphere, the RPR portion of the algorithm takes the first four platonic solids
shape1 shape2 shape3 shape4



and performs a Catmull-Clark refinement on them to generate concentric spheres.

low mediumhigh




This takes care of the center region, but pushing these shapes to higher and higher refinements eventually gets into trouble as the projection of triangles onto a spherical surface isn’t ideal. For the rest of the sphere, the algorithm defaults over to a parameterized spiraling method that just uses 1 parameter, the total number of particles on the surface of each spherical shell, to build out concentric shells.


So far, I’ve used this algorithm for a half-dozen different problems, from the Moon forming impact, to asteroid deflection tests, to a supernova simulation I’ve been looking into. It’s a fairly easy algorithm to implement for any SPH code, and more importantly, it’s a run-time generation method that obviates the need to store libraries of particle arrangements for increasingly high resolutions. Just choose a particle count and off it goes, creating an entire arrangement in just a few seconds.


I’ve benchmarked its stability against a number of other popular generators and published the results in ApJ.

Posted in Research


Screen Shot 2016-02-18 at 1.58.25 PMA little while back, I worked with the VisIT team here at LLNL to create an operator for VisIT that will resample SPH particle data to a mesh for the purposes of visualization. I think the results are pretty nice!

Posted in Uncategorized

Moon Forming Impact

It’s been known for some time now that the Moon formed out of a cataclysmic collision between the Earth and a Mars-sized planet called Theia. What remains unsolved is just how the Moon ended up with so much of Earth’s granite. Every planet has its own, unique mix of Oxygen isotopes – this allows scientists to determine whether a meteorite came from Mars, the asteroid belt, or something more exotic. However, if the Moon formed from the impact of another planet with the Earth, then it, too, should have a unique isotopic signature, except it doesn’t! Moon rocks look almost exactly like Earth rocks! So where did Theia go?

I’ve started a new long-term project to simulate this impact in the hopes of tracking where all the material from both objects goes. So far, all signs point to the Moon forming out of ejected Earth granite, and all of the granite and iron from Theia stayed on Earth. The planet that crashed into the Earth to form the Moon is literally right beneath us, trapped inside the Earth.

impact video

Posted in Research

Initial Conditions are Crucial


Merely placing two compact objects near each other in orbit is not the appropriate way to design initial conditions. In nature, these two stars have felt each other’s gravitational pull for quite some time before the last few orbits (where the merger happens). And so, they should be tidally distorted and not overflowing their Roche lobes at the start of the simulation. I’ve spent a few years now perfecting the generation of initial conditions for white dwarf mergers, and I think this image demonstrates best how accurate they are.

Posted in Research

Tidal Tails

Going to submit a paper in the near term that establishes a new mechanism for producing certain absorption features found in SNeIa. If correct, it can place some very good constraints on white dwarf merger parameters.

Posted in Research