| User | Post |
|
7:47 am November 24, 2009
| Luke Maurits
| | Adelaide, Australia | |
| Admin
| posts 1483 | |
|
|
Post edited 3:30 pm – November 24, 2009 by Luke Maurits
Today I wrote an extremely simple first approximation to the sort of software we will eventually need to use to create our flight plan. It simulates the effects of a Trans Lunar Injection (TLI) burn from a circular Earth parking orbit. One can specify the delta-V of the burn, its direction and the relative position of the CSM and the moon at the time of the burn. The burn is modelled as an instantaneous delta-V and all motion after it is purely under the influence of gravity. For now the program just produces text files containing time series of coordinates. I have been using gnuplot to visualise the results for the time being.
The image below shows the results for a variety of delta-V values, ranging from 0 (in which case the CSM remains in its circular parking orbit, the red case) through 1000, 2000, 3000 and 4000 m/s. The final burn puts the CSM past escape velocity, hence the long, nearly straight aqua line which flies off into the distance. All the lesser burns just put the CSM into increasingly eccentric orbits around the Earth, which are the green, blue and purple ellipses.
 
The image below is zoomed out a lot to show interactions of the CSM's trajectory with the moon. It's not very clear, sorry, I put these together in a hurry. The Earth is located at the bottom right of the plot (at (0,0) on the axes). The red arc is a segment of the moon's orbit around the Earth. All the other lines are CSM trajectories. All the trajectories have exactly the same delta-V, which is why they are blurred together into a yucky yellow-green line for most of the trip. But the trajectories happen at slightly different times, so that they pass nearer or further to the moon. You can see the deflection of the trajectories when they get near the red line, which is the moon's path. The trajectories are being deflected rather sharply by the moon's gravity – I was hoping to find a free return trajectory which would swing the CSM back around headed toward Earth, but couldn't get it to work. I think the CSM is travelling too fast to achieve free return in these simulations, I will have to experiment more later. A quick note on the length of the various trajectories. They all terminate an equal amount of time after launch, so the fact that the light blue line extends so very far after its deflection means that the CSM in this case has picked up an awful lot of speed during its gravitational sling shot!
[Image Can Not Be Found]
The image below shows the same data as the last image, but it is zoomed in on the interesting part, where the CSM's trajectory interacts with the moon's gravity. Note the really interesting loopy structure of the light blue trajectory!
 
That's all for now, these really are the absolute earliest experiments with a very rough play toy. Nevertheless, it seems to be acting sensibly enough and I am optimistic about being able to extend it to be more useful.
Here's a list of things that will need to be tweaked for future versions, which will increase accuracy a lot:
- Currently the equations of motion are solved using Euler's method, which is the most blindingly simple algorithm for numerical solution of DEs there is, and which doesn't have great accuracy. A later version should use something like the 4th order Runge Kutta method for improved accuracy. This really won't be all that hard to implement.
- Real life injection burns will not be instantaneous. They extend over a few minutes, and the acceleration increases slightly over that time as fuel mass is lost. This should not be hard to model more accurately.
- The moon's orbit is modelled as a perfectly circular orbit around the Earth, with a radius that is the mean of the apogee and perigee of the moon's true elliptical orbit. A later version should use the moon's actual orbit. This shouldn't be too hard, either, orbital parameters for the moon will be easy to find.
- Gravity from the sun is currently completely ignored – only the Earth and the moon have any effect on the CSM's trajectory. This may be a little bit of work to add.
- Solar radiation pressure is ignored completely. My intuition is that this will not make a noticeable difference, but if it is easy enough to add, it will not hurt.
- There is no collision detection, the Earth and moon are both modelled as point masses. I'm not unconvinced the super high speed light blue orbit doesn't actually involve getting closer to the moon than its physical radius would allow. This would be easy to check, though.
- Modelling the Earth and moon as point masses ignores the fact that they are not perfect spheres, which has a subtle influence on their gravitational fields. I don't know enough of the relevant theory to estimate either how big of a difference this is likely to make or how hard it will be to improve.
- This doesn't really affect the physical accuracy of the current simulations, but is more about accurately simulating something closer to what will actually happen: we should not assume that the CSM begins in a perfectly circular parking orbit. Rather, we should be able to specify orbital parameters which we can determine from ground observations.
The other big short coming is that exploring the space of possible orbits now is literally a matter of manually guessing good values for all the parameters, looking at the plots, changing them, etc. until you get something close to what you want. A better solution would be to determine some rough heuristics that can automatically ballpark, e.g. the relative position of the CSM and the moon at TLI burn time on the basis of the specified delta-V or vice versa, and then use quickly test a range of parameters within the neighbourhood of that ballpark to find some values that fit the desired criteria.
I will continue work on this software over the next few days and keep you all posted. Once I have some code that is a little bit neater than what I am using now I will start putting copies of it in our DropBox so other people can have a look and contribute. I think developing this program to the point that it enables really smooth and accurate flight planning will be a lot of fun and a great achievement for us! We should endeavour to make sure it is adaptable from CLLARE to later missions. Basically we should end up with something like a completely open source version of the Orbiter software that it was suggested we use for basic planning.
Feedback on anything and everything in this post is welcome!
|
Main CLLARE workgroups: Mission Planning, Navigation and Guidance. I do maths, physics, C, Python and Java.
|
|
|
7:42 pm November 24, 2009
| Luke Maurits
| | Adelaide, Australia | |
| Admin
| posts 1483 | |
|
|
I managed to find a free return trajectory this morning by slowing down the approach considerably. :) Total flight time for this path is about 5.5 days.
[Image Can Not Be Found]
|
Main CLLARE workgroups: Mission Planning, Navigation and Guidance. I do maths, physics, C, Python and Java.
|
|
|
11:31 pm November 26, 2009
| Luke Maurits
| | Adelaide, Australia | |
| Admin
| posts 1483 | |
|
|
I have updated the code used to produce those previous plots somewhat. It now features:
- RK4 integration instead of Euler's method
- Moon follows a Keplerian orbit instead of a perfect circle
- Collision detection
I wanted to put the code in our CSTART Dropbox account but realised I don't know the info@cstart.org account password. If someone could email it to me, that would be great. For now, I'm hosting the code myself here. I've put this version in the public domain since we haven't had a discussion yet about what the official CSTART license will be.
I've really enjoyed working on this. I feel like there is a fairly natural evolutionary path for this program, from a simple lunar TLI simulator to a generic mission planning program that can compute trajectories to anywhere in the solar system. Of course our first use for it will be purely lunar in nature but it should not be too hard to avoid artificially limiting it to the moon as we develop. We can simply have it load orbital elements for a series of bodies in a list, and just set the list to only contain the moon for now. In addition to plotting trajectories it could take care of things like predicting periods of radio blackout (which is just simple geometry – does a straight line from the craft to the Earth intersect any of the bodies), etc.
I would be excited to play a fairly key role in developing this software but don't want to get too carried away before there is some discussion to figure out, e.g.
- What the program should be called!
- What the most useful things to put in the program's scope would be,
- What language it should be written in,
- Which GUI library it should use (which will depend on the above),
- What license it should be under, etc.
Questions, comments?
|
Main CLLARE workgroups: Mission Planning, Navigation and Guidance. I do maths, physics, C, Python and Java.
|
|
|
10:04 am November 28, 2009
| Luke Maurits
| | Adelaide, Australia | |
| Admin
| posts 1483 | |
|
|
Post edited 4:05 pm – November 28, 2009 by Luke Maurits
I found a subtle but serious bug in the code that was posted earlier, which caused the moon's gravity to be repulsive rather than attractive under certain conditions. Oops! A newer, correct version can be found at the same link above. The correct version is letting me produce some much nicer/more normal looking trajectories. Here's a free-return trajectory that doesn't have weird loopy structure.
[Image Can Not Be Found]
Tomorrow I'll extend the code to perform a lunar capture burn, which will produce some nice looking graphs – the green line should spiral around the red line like a telephone cord. Fun!
|
Main CLLARE workgroups: Mission Planning, Navigation and Guidance. I do maths, physics, C, Python and Java.
|
|
|
7:29 pm November 28, 2009
| brmj
| | Rochester, New York, United States | |
| Member | posts 402 | |
|
|
Great work! This is exactly the sort of thing we need! What is this written in? If it's in a language I know, I would like to help if I have time.
|
Main work groups: Propulsion (booster), Spacecraft Engineering, Computer Systems, Navigation and Guidance (software)
|
|
|
7:29 pm November 28, 2009
| brmj
| | Rochester, New York, United States | |
| Member | posts 402 | |
|
|
Post edited 1:31 am – November 29, 2009 by brmj
Accidently double-posted. Sorry.
|
Main work groups: Propulsion (booster), Spacecraft Engineering, Computer Systems, Navigation and Guidance (software)
|
|
|
7:46 pm November 28, 2009
| Luke Maurits
| | Adelaide, Australia | |
| Admin
| posts 1483 | |
|
|
It's written in Python, but I realise that the "real version" of our mission planning software will need to be written in a language that is decided by a group.
If it makes it easier to collaborate with you, I also know C and Java, but I feel like switching to those languages would probably just slow progress down tremendously.
I'm glad you are interested in helping, I'm quite keen to see a good discussion of where this program may go, answering some of the questions I sketched above.
|
Main CLLARE workgroups: Mission Planning, Navigation and Guidance. I do maths, physics, C, Python and Java.
|
|
|
7:01 am November 29, 2009
| Luke Maurits
| | Adelaide, Australia | |
| Admin
| posts 1483 | |
|
|
Presenting the first lunar capture simulation!
[Image Can Not Be Found]
The code has been updated at the usual link. Please be aware that this is an extremely rough simulation mostly for the purposes of having something to show. The timing of the lunar capture burn and its direction are approximations chosen more for coding convenience than actual accuracy, and I just guessed delta-v values until something worked. Nevertheless, this at least verifies that the gravity related code is now obviously working correctly!
|
Main CLLARE workgroups: Mission Planning, Navigation and Guidance. I do maths, physics, C, Python and Java.
|
|
|
12:53 pm November 29, 2009
| brmj
| | Rochester, New York, United States | |
| Member | posts 402 | |
|
|
It's great to see this progressing like it is. Stop for a moment and think about how much harder figuring out trajectories must have been during the Apollo program. With modern computers, you can just use trial and error to get a rough idea, whereas NASA probably used a bunch of really smart people doing particularly nasty calculus or a computer less powerful than a cell phone. This sort of thing makes me feel like we can do this.
I know Java, C++ and a bit of Haskell, and can generally bluff my way through C using my knowledge of C++. A hardely know any python, but it's on my list of languages to learn and I may be able to figure it out well enough to help by reading your code and playing with the interpreter. It seems to be about as easy as its reputation suggests.
Python may actually be a fairly good choice for the final language.
|
Main work groups: Propulsion (booster), Spacecraft Engineering, Computer Systems, Navigation and Guidance (software)
|
|
|
8:00 pm November 29, 2009
| Luke Maurits
| | Adelaide, Australia | |
| Admin
| posts 1483 | |
|
|
Computers really do make this sort of thing so much easier. I imagine Apollo was probably largely done using approximations and hand calculation, it would have been nasty. The upside to that is that it means super accuracy obviously isn't necessary to still pull things off, which is reassuring.
I don't know any Haskell, but it has been on my to do list for a long time since a co-worker recommended it to me. As a mathematician I find a lot of its syntax really appealing and intuitive, it may be a good choice for this sort of work.
At the same time, I know Python really well and can develop in it pretty quickly. It has a larger user base and lower learning curve than Haskell, and lots of well written and tested libraries, including plenty of stuff for scientific applications. There are lots of tricks you can pull to improve performance, and in a worst case scenario, I understand it is pretty easy to embed C code inside Python if you really have to for speed. I'll admit I've never done that, but a lot of people have told me it is quite easy.
My code for producing these plots is probably a terrible way to learn Python, since I have just thrown together the simplest thing that could work, there are very few functions, no use of objects, it looks more like a shell script than anything else. Once we decide on a language and other particulars we can rewrite it properly, with CelestialBody and Spacecraft objects, etc. One thing I'd really like to see ina proper version is adaptive changing of the time step used in the numerical plotting of trajectories. Nearby to Earth or the moon where a lot of stuff is actually going on, you need to slow time right down to get an accurate curve, but during the approach phase when both bodies' gravity is fairly week you can afford to speed things right up.
I feel like I have enough rough ideas to start writing a Wiki article outlining what our proper software will look like, but I haven't created one yet because I don't know what to call it!
|
Main CLLARE workgroups: Mission Planning, Navigation and Guidance. I do maths, physics, C, Python and Java.
|
|
|
8:31 pm November 29, 2009
| brmj
| | Rochester, New York, United States | |
| Member | posts 402 | |
|
|
"I don't know any Haskell, but it has been on my to do list for a long time since a co-worker recommended it to me. As a mathematician I find a lot of its syntax really appealing and intuitive, it may be a good choice for this sort of work."
Agreed. It is quite well suited for this problem, actually. I'm just in the process of learning it myself, but I already know several tricks that would make this quite a bit easier.
"in a worst case scenario, I understand it is pretty easy to embed C code inside Python if you really have to for speed."
Not an advantage over Haskel, for the record. Haskel can be compiled into C. This does open up the possibility of writing it in a combination of Haskell an Python, incidentally. Haskell is far more suited to the inner workings of this sort of thing than it is to the user interface and so on, so something of that nature might not be as bad an idea as it first appears.
"My code for producing these plots is probably a terrible way to learn Python…"
Point taken. Doesn't invalidate the basic idea, though. It shouldn't be that hard for me to pick up a basic working knowledge of python if it becomes necessary.
"CelestialBody and Spacecraft objects"
In case this was closely related to your notion of how this ought to be done, and not just how it ought to be done in python, please try not to be locked into the OOP way of doing things. There's an excellent chance that that's how our final version will work if we don't use Haskell or similar for the inner workings of it. If we do, however, I imagine we will do it differently. OOP doesn't work so well in a language where state is frowned upon.
|
Main work groups: Propulsion (booster), Spacecraft Engineering, Computer Systems, Navigation and Guidance (software)
|
|
|
10:12 pm November 29, 2009
| Luke Maurits
| | Adelaide, Australia | |
| Admin
| posts 1483 | |
|
|
Not an advantage over Haskel, for the record. Haskel can be compiled into C.
Oh, sure. That comment was not supposed to be in defence of Python as a better option than Haskell, it was supposed to be in defence of Python against the anticipated "interpeted languages are too slow!" crowd. Force of habit, sorry!
In case this was closely related to your notion of how this ought to be done, and not just how it ought to be done in python, please try not to be locked into the OOP way of doing things. There's an excellent chance that that's how our final version will work if we don't use Haskell or similar for the inner workings of it. If we do, however, I imagine we will do it differently. OOP doesn't work so well in a language where state is frowned upon.
Yes, this was me thinking in terms of a future Python version. If we did end up going with Haskell I feel it would take me a little while to shift gears since I do tend to think in OOP terms as a habit. I'm not necessarily opposed to going with a non-OOP design, although I worry that doing this might drastically cut down on the number of people who can help us. Good coders who can work well within OOP are a dime a dozen, people who can work well in a functional manner are more rare. It would have to be looked at as a cost/benefit tradeoff situation.
From my perspective (and admittedly I'm quite biased), I think OOP works quite well for this sort of thing. I can sympathise with the idea that sometimes OOP can seen unatural and constraining, but in this case, celestial bodies and spacecraft really are physical objects, they do have dynamic state variables. The OOP way of thinking and the physics way of thinking go largely hand in hand. But this may well be ridiculous argument from the point of view of someone with more functional experience.
|
Main CLLARE workgroups: Mission Planning, Navigation and Guidance. I do maths, physics, C, Python and Java.
|
|
|
3:59 pm December 23, 2009
| Jasper
| | Eindhoven, The Netherlands | |
| Member | posts 3 | |
|
|
Nice posts. I did find the little loop strange(As orbits are either elipses, hyperbolas or parabolas on the edge), but i thought it was due to the moon moving. The lisp code on gravity i wrote should be fairly easy to convert to Python/other languages, but i am not sure how well the CLOS methods and setf-functions will translate. (But it will be good enough.) Not that code for small gravity variations is particularly useful at this point..
In lisp I like the 'OOP', but CLOS just seems to do it so much better then C++(and presumably other languages), i find the "." notation of the methods so awfully silly, so i can't say i like the idea of using OOP in other languages..(I tend to write almost everything functionally even if it also uses CLOS deriving classes) I can't say my opinion should weigh much, though.
I don't know Haskell much, was learning it for a while but got distracted/annoyed. It does seem like a good language to me, if you know it. If you don't you're like wtf give me a damn way to set a variable, i haven't yet figured out how to deal with that.(I am sure it can change state, but not necessarilly via setting a variable.) Probably if i do know how to change state i can get more motivated in learning the rest. (In general you need state changes in simulations, when defining/loading something or perhaps as part of some function which you keep externally functional but uses changing variables internally.)
|
|