Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Friday, July 11, 2008

Eradicating Bugs Since 1978

Spent some time this evening debugging the climber logic. The climbers are represented by an array of class objects, and I hard coded access to the first and only item in the array. Since it was late at night, I coded indexed position one instead of position zero, so was throwing an exception. It took about five minutes to track down. I now have the model running with a climber for the first time. The model is running significantly slower now, partially because I restructured some of the larger methods into smaller, crispier pieces. I need to look into some performance improvements (besides just re-writing the model in another language.).

I have a class tomorrow afternoon, but will work on the model in the evening or a few hours on Sunday.

Tuesday, July 8, 2008

Climber Work

Worked on the climber algorithms tonight.

For a ribbon segment without a climber or other ribbon furniture, the forces on the ribbon follow Hook's law, where the distance between the start point of two ribbon segments is compared against the initial segment length to compute the forces exhibited by the two segments on each other.

For a segment with a climber, I break the ribbon segment into two pieces, one 'below' the climber and the other 'above' the climber. If I can accurately state what the initial length of each of the pieces of the resulting ribbon is, then I can compute the forces on the ribbon segments and climber by calling the simple ribbon segment dynamics. I've already developed the method that checks when a climber has transitioned from one segment to the next. The missing pieces are computing the force that the climber applies to the ribbon, computing the amount of 'initial length' of the ribbon that the climber will cross in a simulation time increment, and to modify the old climber dynamics routine to the use the new methods.

Tuesday, June 10, 2008

Phantom Quelling

I thought that allowing the elevator a period of unchecked dynamics was allowing it to sort out the forces on the ribbon. It turns out that it was allowing the double precision floating point numbers overflow, and become NaN (not a number) in Java.

I need to review the equations again, to figure out what I introduced into the model when I converted it to Java. One of the changes was to use the vecmath library, where I may have swapped some of the parameters when I converted to the new routines. Again, I need to walk the code to determine if this is the cause of an issue.

Saturday, June 7, 2008

Restructuring the Model

The ribbon in the original C code was represented by an array of ribbon segments, which act like a set of masses connected with springs. The simulation typically works sequentially through the list, with a couple of places where pairs of adjacent points are processed.

In the model, the climbers are held in a separate data structure. There is a little book keeping to determine which ribbon segment the climber is attached to, and then the climber forces on the ribbon due to acceleration are computed and applied. The ribbon forces on the climber are approximated, with a tendency to move the climber towards the ribbon if it starts drifting away.

If the representation of the ribbon was moved from an array to a linked list, then the climbers could be added into the list between ribbon segments. The climbers would become very short ribbon segments with a higher mass, and the length and tension of the segments above and below each climber would be adjusted to represent the climber moving along the ribbon. The existing ribbon and point dynamics routines would then be used to compute the ribbon effects on the climber.

Java has a LinkedList class that is part of the AbstractCollection class, so it should be fairly quick.

First Weekend Task List

In Eclipse, I ran SEsimOne for eleven hours of simulation time at quarter second time increments (only an hour of which was for quelling the simulated ribbon). There is dynamic allocation for temporary classes in the ribbonDynamics and pointDynamics methods, which I should be able to clean up. ribbonDynamics is called over one hundred and sixty thousand times (the current length of the simulation), and pointDynamics is currently called a thousand times more than that (the ribbon currently being represented by a thousand segment points). I want to be able to increase the number of segment points in the ribbon, especially the parts closer to the ground that are in higher gravity. I am also impatient, so I need to start thinking about performance improvements.

Task List for this weekend:

in ribbonDynamics, stop propagation across ribbon breaks (skip over the gaps)

walk the code to verify that timeStep is correctly included in all equations.

add climbers back onto to the ribbon.

restructure to create a ribbon class. The ribbon behavior is spread over the SimRibPoint class and methods within the main class. may want to subclass the anchor and counterweight points.

performance improvements

start reading Java3d documentation and tutorials

Friday, June 6, 2008

Partial Progress

I discovered a typo in the pointDynamics code during lunch today, where I had multiplied a value by the mass of a segment instead of dividing, which was messing up all of the velocity vectors for the ribbon segments. This was what was popping the last segments off of the elevator during each iteration.

The ribbon starts breaking now on the eleventh iteration through the ribbon dynamics code, near the base, at the second segment above the anchor. Just need to track down the bug I induced that is causing the problem.

Thursday, June 5, 2008

Debugging the Sim

I'm working at debugging the simulation.

I discovered that I had neglected to increment the current time variable, and once I did, the ribbon started fragmenting. It turned out that I had made a typo in the equation to compute the loading on a ribbon segment as the forces are propagated. This caused the computed loading on every segment to be too high, and tripped the ribbon break code.

With that bug fixed, the next problem is that the next-to-last segment of the ribbon breaks in the first iteration. The last segment remaining on the cable snaps for the next four iterations, the loads building, and then the ribbon snaps off near the ground and starts to disintegrate. I need to check the boundary conditions on the ribbon (what happens as the sim approaches the end of the ribbon) to solve the first problem, and then walk through the original code versus my implementation to see what I missed or messed up to cause the subsequent problem.

For now, I have disabled the climbers and code to compute the effects of the climbers to simplify the debug of the ribbon. One of the equations that I need to look at is computing the motion of the elevator along individual ribbon segments, and how it transitions to other segments.

My First Java Simulation

About three and a half years ago, I ran across the simulations of a ribbon break in the space elevator that Blaise Gassend had posted on his website. He was generous enough to include the C source code.

At the time, I had planned on re-writing his simulation in Java, both to learn how the simulation was put together, as well as to polish my programming skills in that language. My plans had been to write a simulation that would be accessible from a web page, exposing enough knobs and levers into the simulation to allow users to play with it. I was also interested in simulating a 'space hoist', a variant of the space elevator discussed on the Liftprt discussion boards which uses a looping, untapered ribbon that is moving.

I stopped working on the project at some point, and it sat in a folder on my bookshelf ever since.

Last week, I ran across all the notes, and decided to give rewriting the simulation another go. I downloaded Eclipse as my development environment, and used the javax.vecmath package from java3d as a vector math library. I'm only able to work on the project late in the evenings after dinner, and typically after my daughter goes to bed. I got the 'math engine' parts of the simulation up and running last night in Java, and am working at doing a little more class restructuring to make it look less like C. Once that is done, I need to build and code the graphics portions of the simulation, as well as whatever user controls that I want to put in place.

I want to get a working version equivalent to the one Blaise had running first, and then start playing with variants. Two variants that I would like to do are the aforementioned 'space hoist', as well as a simulation of a space elevator on Saturn's moon Titan (where Saturn's gravity needs to be accounted for as well as Titan's gravity, and perhaps some of the other moons as well).