Saturday 29 September 2012

Fizzbox Goes Online!

After a lot of leaning how stuff works I've finally got something to show for my time online.
Fizzbox.com was unavailable as a domain name (taken by a silly company who buys the internet and sells it for more than its worth).
So I've gone with a domain that reflects the tagline, A Universe In A Box.

Find me at universeinabox.com.

As I write this there are still quite a few broken links, non - existent sims etc. to sort out, but I was just super excited creating a website so I put it on unfinished.
I'll get some of these things done as well as some more simulation things in the next couple of weeks. Keep an eye out!

Wednesday 15 August 2012

Fizzbox's Second Sim

Last time I promised I'd get started on an ideal and non-ideal gas movement simulator. Well I didn't. I got distracted working on my new website (not online yet...) which is looking super cool now. Keep an eye out for news on that! I've been using Bootstrap, a beautiful web design tool made by the creators of Twitter (see shameless link to my own twitter page). It's pretty much done thanks to Bootstrap's simplicity but it's lacking in content. I think I'll fork out for a domain name once I have another two sims to show off.

With that in mind I've been working on a very simple simulation of a mass-spring system. Writing a second sim was a million times easier than the first - not much more work than deleting all the code that had anything to do with gravity and sticking some springy stuff in there instead. This is just first draft, and its not interactive at all at the moment. There are two mass-spring systems with slightly different initial conditions. The idea will eventually be that you can choose the setup yourself and see the effects of the changes you've made by comparing the two systems. Here it is in all its simplish simpleness:

http://pastehtml.com/view/c8cbm9i4f.html.

As this sim is much simpler I thought that before it gets more complicated should share the source code. All of the interesting physics happens in the function called 'step'. If you're an A-level standard physicists or above should be able to see what that function is doing using a bit of your integration knowledge. BoxA and boxB are the two masses. I'm not going to annotate this line by line but I'll happily answer any questions posted as comments if I'm able. Here it is:


Saturday 11 August 2012

Gravity Simulator Draft 2

I've made some decent changes to my Gravity Simulator in the last few days. I'm quite happy with it now and I think I'll be leaving it alone for a while to get some other sims on here.
Here's what to do:
  • Click and drag to create a planet of random mass, with speed and direction determined by your drag.
  • Add or remove the Sun using the tick box and the update button underneath.
Firefox and Internet Explorer users will have to follow the link below for this to work (sorry!)


Fizzbox Gravity Simulator draft 2:



Add Sun

There are a few features I'd still like to add to this like a slider to choose planet mass and saved data for real planets in the solar system, but they can wait till I launch a proper website. Until then I'll be writing a simulation of ideal and non-ideal gas movement. Keep an eye out for it!

Thursday 9 August 2012

In Between Drafts

Things are starting to pick up! Lots of bugs fixed over the last few days including the last blog post's 'ping effect', achieved about 2 am this morning after a few hours of zombie-ish stabs in the dark (I can't even work out how I fixed it now).
It all looks a lot better now, and it runs way better too with these new features:

  • Random planet mass:  clicking creates a planet of random mass, making orbits much more interesting. I'm working on a slider to allow the user to choose mass ready for the next draft.

  • Set initial velocity: Click and drag anywhere on the screen. The created planet now sets off with speed and direction depending on your drag. Next draft will make it look a lot neater by drawing an arrow while you drag.

The most up to date draft of Fizzbox Gravity Sim:




Firefox and Internet Explorer users will have to follow this link:

I'm still hoping to deliver on my 'Good things to come' promises (see Teething Problems) and I'm working on a few more cool features for the next release, which I'm hoping to release as an app on the Android Market.

Monday 6 August 2012

Teething Problems

The first draft of Fizzbox gravity is done - here it is in all its glitchy badness! Click in the box to make a planet.


There are loads of annoying problems to sort out, some I understand, some I don't.
I promise you won't need to understand much physics to enjoy most of my sims, but some boring geeks like me might want to know what's gone wrong. Non geeks could skip to 'Good Things to Come'.

Ping Effect: Make two planets very close together. You can do that by clicking twice in the same spot relatively quickly. The planets will accelerate towards each other before shooting off, sometimes too fast to see. This is to do with the Integration technique, Euler Integration. A thousand times a second this program calculates the force of gravity due to each planet on every other planet. When two planets become very close, the force of gravity between them is very strong causing huge acceleration. In a thousandth of a second the virtual planet will shoot past its partner to a point were gravity is weaker, and fly off. 

In our Universe, this obviously doesn't happen, for two main reasons. Unlike those above, real planets aren't point sources of gravity - they have a size. Unless two point sources come together, there's no problem. Secondly, there's no time delay between 'simulation steps' in the real world. You could think about the Universe doing an infinite number of calculation sets every second, rather than a measly thousand. Alternatively you could just accept that the Universe doesn't bother to do integration, it just happily physicses along physicsly.

I've put in two fudgey fixes to this problem:
  • Gravity 'switches off' when planets come within a certain distance of each other. You might be able to see this if you watch a collision carefully. This is a horrible fix and I hope I can get rid of it asap, possibly by allowing planets to bounce off each other. I wonder if I could just spread the mass through  the disk of the planet instead - more like the real case?
  • Planets start with random initial speed. You can see this by clicking once - the planet will move even though there are no other planets to interact with. That makes two planets less likely to cross paths. This isn't bad physics, since the Universe didn't just start out as a bunch of stationary planets wanting to interact.
There are more problems which I don't get. I'm not convinced that all the planets 'notice' each other. Some just don't seem to interact. Fix to come soon (hopefully!).

Good Things to Come: After a few hours of bug fixing there are a few cool things I can do to make this way more interesting. Watch out for the next draft in a day or two:

  • Choose the mass of a planet. I think this would be done by the user holding the mouse button down as the planet grows.
  • Set initial velocity. This should let you set up interesting orbits.
  • Set up our solar system. I'm hoping to set up a sim with real data to model our system. That way you'll be able to edit it and see how things would go if something were different.
  • Planets that aren't just red dots! Expect to see the sim looking a bit less boring next time.


Friday 3 August 2012

Nexus 7

Nexus 7 due to arrive next week.
Challenge: Can I write a cool simulation to show off on it before it does?

Aiming for a web based version of my old Gravity sim.
Spec: interactive, tablet friendly, not horrible looking, smooth-running, orbit friendly, easy to use.

http://www.google.co.uk/nexus/#/

Thursday 2 August 2012

Fizzbox intro

Last Summer I started to learn programming for the first time. I used python to do numerical simulations of physicsy things - simple harmonic motion, planets moving under gravity, that sort of thing. To turn numbers into interactive, visual simulations I used a set of modules called pygame. I had the idea of setting up a site with a series of interactive simulations to share online. I didn't get very far.

The only simulation to make it online was a gravity simulator. Very simple stuff - click the screen to create a planet (boring dot) with a fixed mass. Two or more planets will interact under gravity. It wasn't very impressive. The main problem was that the planets started with no speed, so it was tough to set up interesting orbits.

You'd need to download a huge zipped folder and extract it just to run the simple program, which ran annoyingly slowly.

Starting this Summer I'm going to start the Fizzbox program again from scratch on here. I'll put on all the bits as I make them before stringing them all together on a new site, which I ambitiously hope could be used in school physics lessons.

There'll be more posts to follow explaining how the new programming will work, and what Fizzbox will hopefully eventually look like. Subscribe to see the fizzbox project unfold from the beginning!

About Me

My photo
Manchester, United Kingdom
Second year physics student at the University of Manchester, interested in simulation and education.