Entries Tagged 'Physics' ↓
June 29th, 2005 — Physics
Exams are over for another 6 months, so I’m starting work on next year’s project. Because I’m going to be producing 10-20 000 words in total for my Masters report, and also writing course material, I have decided it’s time to raise my sights above Microsoft Word. I love beauty, I love the flow of well-typeset prose… all of which points to Latex.
The problem is… I am actually a very visual person. Sure I program, but only if the code I write is colour coded. My other hobbies are much more artistic. So writing Latex commands by hand is not attractive.
I’ve therefore been casting around for visual latex editors. 3 years of being a student is taking its toll, so I’m not buying any software (incidentally, I’m undertaking freelance web design/programming work over the summer - “contact me”:peter@mapledesign.co.uk if you have a project that needs completing).
Ideally any solution would run on Windows XP as that’s what I’m used to and have everything else running on.
I first looked at “LyX”:http://www.lyx.org/ which I remembered from the past. However its Windows port didn’t seem to have progressed far (previously I’d tried it and had problems), so I continued looking.
If I wanted to write LaTex by hand, “LaTeX Editor”:http://www.latexeditor.org/ looks ideal, and definitely worth anyone checking out as a replacement for WinEdit.
One option could be to use OpenOffice. There are some interesting addons to help with LaTeX - “OOoLatexEquation”:http://www.fyma.ucl.ac.be/wiki/~piroux/OOo macro to allow Latex equations to be inserted into OpenOffice documents; or an “export converter”:http://www.hj-gym.dk/~hj/writer2latex/ to produce LaTex files from OpenOffice documents.
While not free (I’m weakening…) “BaKoMa TeX Word”:http://www.ctan.org/tex-archive/systems/win32/bakoma/ promises “true WYSIWYG LaTeX editing”. I haven’t given it a test drive yet, but will do so very soon.
As the report I’m producing isn’t terribly mathematical, maybe I am wrong in looking at LaTeX to provide decent typesetting? Perhaps there’s another solution that would work just as well?
Particularly for course material (which is for an introductory programming course) I’m very tempted to write it in XHTML, as I wamt the online course notes to be interactive with quizzes etc. Although then I have the problem of getting nicely-formatted printed notes…
December 21st, 2004 — Physics, Python
One of the work items that kept me occupied over the past week was writing a computational physics simulation modelling “quantum potential wells using a Monte Carlo simulation”:http://www.phys.soton.ac.uk/teach/year3/notes/ph314/projects/pjtb2.pdf.
I chose to write the simulation in “Python”:http://www.python.org instead of C - my feeling was this would be quicker to get a working simulation with, and I could always rewrite in C if it was very slow. i didn’t expect it to be - I’d read a lot of reports about Scientists using Python, so figured it would fine. I also picked Python as this would force me to learn the language, something that if I pursue “a particular route”:http://www.ses.soton.ac.uk/projects/Comp_Eng_Des/comp_eng_des.html after graduating would be very useful.
Due to some problems, the lecturer overseeing this simulation ended up writing the simulation also, in the departmental version of Basic.
At that point I realised how slow the Python code was. I didn’t expect it to be as fast as C, but was surprised by how much faster the Basic version was. It wasn’t impossibly slow, but running a million random walks of up to 300 steps was taking nearly 2 hours to complete. I tried plugging in Psyco to speed up the Python code, without much luck.
I don’t know if there were ways to get the Python code faster (short of using Pyrex), but I’m posting the code here to see what people think. Given it was the first proper Python program I’ve done I expect it to be a bit slow, but wasn’t expecting it to be this much slower.
One other point that came out was that the Python code produced a greater scatter on the results than the Basic version. I think this has to come down to the random number generator, but thoughts on this would be appreciated as well.
To the code:
* “Python code for a 1 dimensional potential well”:/physics/simulations/rand_walks_qm/1D_0.py
* “New Forest Basic code for a 1 dimensional potential well”:/physics/simulations/rand_walks_qm/1D_0.nfb (slightly more basic than mine - walks aren’t killed after X steps, but continue to arrest). You’ll also need the editor/compiler/interpreter (”Windows”:http://www.phys.soton.ac.uk/teach/year2/notes/lab/software/nfbwin.exe or “Linux”:http://www.phys.soton.ac.uk/teach/year2/notes/lab/software/nfblnx) - which in turn requires “TCL”:http://www.tcl.tk/ to be installed.
* Python code for a 2 dimensional potential well (”ground state”:/physics/simulations/rand_walks_qm/2D_0.py , “first potential”:/physics/simulations/rand_walks_qm/2D_1.py , “second potential”:/physics/simulations/rand_walks_qm/2D_2.py ). Note that this code does not relate well to the real values expected; I didn’t work out what the problem was before I had to hand in the report.
I just ran across dirtSimple’s post “The perception of speed”:http://dirtsimple.org/2004/12/perception-of-speed.html today, so it seems I’ve written this post at a time when the subject’s topical 
December 3rd, 2003 — Physics
Today I wrote a small “demonstration of the Coriolis effect”:http://peter.mapledesign.co.uk/code/Coriolis.py in “Python”:http://www.python.org/, using the “VPython library”:http://www.vpython.org/ to provide the 3D graphics. I was inspired to do this by a “Mathematica”:http://www.wolfram.com/products/mathematica/ generated picture in our notes of the same thing, and it looked an interesting shape to model. Plus, writing the demo would help me to follow the formula given in the lecture notes 
On a related note, there’s some other good physics demos written using VPython “available”:http://www.physics.syr.edu/%7Esalgado/software/vpython/ and that site also lists many useful links.
I’m finding VPython very basic and not flexible enough, but at least it saves me using “PyOpenGL”:http://pyopengl.sourceforge.net/
December 1st, 2003 — Physics
After returning from a very intense 2 hour session with Dr. Moretti this afternoon (which was well worth the mental effort involved) I decided to try my hand at writing a little simulation of the effect of the Coriolis force on the trajectory of a cannon shell (with the Earth’s angular velocity increased to make it visible). Why did I pick this? Well, we have a nice 3D diagram in the notes which took my fancy, and I could see a “blow up the exam papers” game evolving.
Not being the kind of person to have small ideas, I decided immediately on a 3-d visual demonstration - and it would be nice to make it into a game as well, so that people were bothered to learn using it (don’t ask me who, but in everything I have grand ideas!).
A quick look around suggested using Python and “VPython”:http://www.vpython.org/ would be the simplest way to get started. An hour was long enough for me to get familiar with the examples and a little bit of the documentation and to have started writing the code. I got to the stage of a normal trajectory, and then stopped writing. I’d had visions of using images for the objects, and what did I have? A green square for the ground; two spheres and a broken trail behind the projectile. Good enough to give an idea, but not exactly realistic. Or inspiring.
So I did more surfing. Which didn’t really turn up anything useful. One of our lecturers last year (now sadly “moved on”:http://www.phys.warwick.ac.uk/current/directory/staff/marsh.php) wrote quite a few 2D simulations in Java or C++ (we saw some very nice gas simulations for thermodynamics). So this might be more profitable (C++ anyway, never used Java)
Is this the best I’m going to be able to do? Somehow I think so, which is a little disappointing. I think Flash might provide another method to make it look more pretty, but it would be a lot harder to write (due to a lack of libraries and lack of knowledge of Flash). I’ll persevere with the python solution
November 25th, 2003 — Physics
Only a link dump for now:
* “Newtonian Gravitation and the Laws of Kepler”:http://csep10.phys.utk.edu/astr161/lect/history/newtonkepler.html
* “Kepler’s laws proven”:http://dept.physics.upenn.edu/courses/gladney/phys150/lectures/lecture_nov_29_1999.html
* “Lecture slides on Gravity & planetary motion; Kepler’s laws; Energy and escape velocity”:http://www.phys.uconn.edu/~rcote/Courses/PHY151/lec28.pdf
* “Worked questions about satellites orbiting the Earth etc.”:http://www.br.psu.edu/faculty/lht1/concepts/harvard/lectures/lect15.html
* “Problem sheet soln on some gravitational stuff”:http://phy-lyman.princeton.edu/~page/phy105/03/ps7_soln.pdf
August 5th, 2003 — Physics
Subject index of Alternate View columns by John G. Cramer
“The Alternate View” columns of John G. Cramer are short (~2,000 word) essays about cutting-edge science. They are aimed at readers (and writers) of “hard” science fiction, as exemplified by the SF stories of Analog, but are about real science, usually physics or astronomy.
Link via “Kyrogenix”:http://www.kyrogenix.org