Wednesday, November 25, 2015

Kerbal Space Program AAR, The First Orbit

We were officially a space program now, but there was so much still available to us. We had only scratched the surface of what was above-ground. As usual, the first step in our next endeavor is to see what contracts we can find. One comes to mind. It's time to get into orbit, the real first step of any serious travel in space.

While I'm at it, an engineer offers a small contract to use their newly developed booster to help us into orbit. They pay for the booster's cost and give an additional small bribe payment.

Getting into orbit with our current launchpad is possible, but given our current funds, we should have enough to build our rocket and upgrade the launchpad at the same time.I ok the upgrade, and my lackeys get to work.
The new pad can support a whopping 140 tons, whereas the old was limited to a mere 18. We won't be limited by the launchpad for some time. It's time for me to begin my design work.

As I'm working, my researchers come to me with a big development. They've got a new type of fuel and engine for us to use. Essentially, we mix lamp oil (aka Kerosene) with liquid oxygen (usually known as LOX), rather than using our solid rocket fuel. The big benefit is better performing rocket fuel, especially when there's little or no atmosphere. The downside is the engine is expensive, so we're better off using our traditional solid fuel boosters to begin with.

Eventually, after much testing and simulation work, I settle on our new design:

Heh, it looks like a -
Legal adviser: "Don't finish that sentence."
For once, I listened to him. The new rocket used our new liquid fuel engines, along with a new concept called "staging" where we ditch parts of the rocket as they run out of fuel. My engineers were happy as it meant they could use explosives. I do admit that planned explosions make for a good view.


The rocket is brought out to our shiny new launchpad, and our pilot Ms. Health suits up again.

The trip should be straightforward: Set off the three bottom boosters. Dump the two on the sides when they empty

 and drop the big one soon after. This should get us out of most of the atmosphere.

Continue boosting with the final engine, turning towards the east. Turn the rocket off once we'll reach 70k km, putting us out of the atmosphere.

Coast until we're almost out of the atmosphere. We want to get as much out of our fuel as we can. Then, we face straight east and go for a full burn 

until we get on a proper orbital course. We'll know we're on the correct course when we go around the planet without ever touching the atmosphere.

Success! Our periapsis is above 70k km! My legal adviser insists I use these names for our flights. Periapsis stands for the lowest point in an orbit, while apoapsis stands for the highest point in the orbit. High point and low point are trademarked, or so I hear.

We have Ms. Health go around the planet twice. It's very strange to have someone go by at 2200m/s without any active propulsion. As she comes around again, we go for something different. She's got plenty of fuel left; we could deorbit now, but we could also go further. The people in charge have decreed 250,000km out to be "very far into space". We can easily reach that far and still come back, so I have Ms. Health prepare for the next burn.

Which comes to the weirdest part of orbital mechanics. In order to reach a higher point in space, we'll thrust into our orbit. In this case, that means we're thrusting straight east in order to go up.

Everything completed, we wait 30 minutes for her to come to the apoapsis.

Well said. We finish our observations and begin the trip back. Unsurprisingly, if thrusting into our orbit sends us further out, thrusting against our orbit brings us closer. In this case, closer means coming back into the atmosphere.

All that's left to do is wait. As we hit the atmosphere, we jettison the engines and tanks, and have the heat shield protect the craft.

Then we watch as 2000m/s of speed is burned up in the atmosphere.

Letting us gently fall to the sea for the last 300 meters.
Leaving us with another successful mission, and some much needed Science!
Now the fun times could begin.

PS. I went into more detail this time around because getting into a basic orbit is the bread and butter of space travel. Bonus picture from testing:

Tuesday, November 24, 2015

Kerbal Space Program AAR, the Flight to Space

I needed new kerbonauts if I wanted to continue the program, so I put out some ads. Pilot funny looking rockets! Enjoy the emptiness of space! Get as far away from other Kerbals as can be possible! Join our space program today!

My legal adviser advised me again that as we hadn't been to space, then we couldn't call ourselves a space program, and could be held liable for false advertised. I ignored him again. Surprisingly, we didn't have long until we got our new first new applicants. After applying our rigorous tests to determine the best applicant (first come first serve) we had our new pilot, Lisya"Health" Kerman.


Hopefully her nickname is a promise of things to come, and not her being ironic. I quickly shuffle her off to basic pilot training and move on to designing a proper rocket for going to space. This time I'd go through some actual planning and design, along with making sure to run it through simulations first. I didn't like Jebediah, but his death will spur me to do things right. I get a basic design down and run simulation

after simulation

after simulation

until I'm sure that I've got something workable. Short of gross pilot error, this rocket would not be destroyed because of my design.

With the design done, and Ms. Health finishing her basic training, I giver her a quick briefing before she steps into the new rocket.
"The flight is simple, keep the rocket facing straight up. Press this first button to start things, then this next button when it lights up, followed by this third when it lights up. Supposedly, you'll go higher if we stagger the rockets, rather than lighting up them up all at once. Don't press any other buttons. We'll give further instructions when you've left the atmosphere"
There were no comments or questions, and so we set up the launch.


We got the rocket on the launchpad, all lights were green for launch. I gave the go-ahead for the countdown. Ms. Health begins counting down steadily:
3
.
.
2
.
.
1
.
.
Press all the buttons!

My assistant came over with an outstretched hand, asking me to pay up on our bet. I grudgingly gave him the money. But we had planned for this. Even if she launched all the rockets at once, she wouldn't blow up, nor fail to make the required height. Everything was going well, even if I was down 100 spesos. I held my breath as she passed the danger zone, where her large speed would compress the air. Compress it too much, and the buildup of heat would blow up the rocket, as had happened so often in the simulations.

But she made it through, even if some warning lights were a tad angry with us. The craft continued coasting, getting ever closer towards that magical 70k marker, where it would leave our atmosphere and truly enter space.


We reach it, and our pilot gives us a few observations. Success! We're officially a space agency now. The craft continues climbing towards that 150k marker that we need for the extra cash.

We reach it, with some distance to spare. Even better, we get a picture of a future destination. Well done. But now it's time to bring our pilot back, and the planet looks much different when you're falling into it from 150k kilometers up.

I give her the remainder of her instructions. "Flip the switch on your left to jettison the empty tanks. You won't need them any longer. Then flip your craft nose first towards the ground. My researchers tell me that their funky shape is deliberate. If it works as designed, it'll end up bottom down no matter your orientation, and they won't to test it out. They tell me the risk is minimal. On the right is another switch for the parachutes, flip it when the light turns green. Please wait this time before hitting it"

Everything looks good, and it's time to see if everything works out. Will she burn up on reentry? Will she pop her parachute at the appropriate time? Will it slow her enough? All these worries fly through my head.

She's well into the atmosphere by now, and unsurprisingly (or surprisingly, depending on how much you trust the researchers) the craft has turned bottom down. Neat. Now to see if it would explode from the heat, or if something will go wrong with the parachute or...

But no. Everything goes perfectly well, and Ms. Health lands perfectly. Even exiting the craft for a quick picture. Success! First manned mission to space!


Monday, November 23, 2015

Kerbal Space Program AAR, Science!

After our first successful flight, we had a minor celebration. All had gone well, and while there was some minor tension between me and the new hot-shot pilot Jebediah, we could still work together.

Enough reveling, next step to space was to visit Research and Development to see if they had any new parts. I didn't want to continue using model rockets if I could help it.


Here's the tech tree. We use our Science! to research new sets of parts. Of course, nothing is actually free - all new parts that have been researched will require an additional fee to prototype. The new parts we've made available will do nicely. Now, instead of the model rocket we were using before, our researchers have a new rocket that works the same, but has the fuel of two model rockets. Progress, I suppose.

Next, I rifle through the available contracts, looking for more work to fund the program. Two contracts immediately present themselves:


It's time to actually reach space, rather than staying in the atmosphere. Which, as my legal adviser is so eager to point out, will allow us to legally call ourselves a space program. We still call ourselves a space program, but don't tell anyone. We're hoping the feds don't notice before we get a rocket up there. While we're at it, I accept the challenge to haul our new and improved booster rocket up to at least 150k km. 

Just as I'm about to leave, my head researcher informs me that with a simple mission like the first, we could research aerodynamics, which would vastly improve our rockets. Without them, the challenge would likely be undoable. I approve the mission and have Jebediah suit up for what should be a walk in the park.


A simple mission. Launch, collect some data, and return safely. Just the same as the mission before. All is going well, until disaster strikes. The hastily made design returns to the ground nose first. Unlike our first flight, the craft doesn't lose enough speed coming down and is moving too fast for the parachutes to safely release. Jebediah makes tries anyway, and the parachute disintegrates.


What should have been a routine mission ends in disaster. The craft is destroyed on impact, taking the pilot Jebediah with it to a watery grave.


Morale is low. Our backup pilot Valentina is suited up for a similar mission. This time, we're back to the tried and true model rocket. It won't go high enough for another crash.


The mission is a success, with Valentina splashing down safely. Once she returns, I go to congratulate her, only to find myself met with a declaration: My pro kerbonauts were on strike while I was in charge. Turns out, they didn't think it an accident that Jebediah died earlier. If I wanted to take this agency into space, I'd have to recruit new, untrained kerbonauts.

PS. As an aside, I make sure to record everything I do. If you're interested in seeing what happens in video form, I should be able to upload that part to youtube. Most of what happens is boring, so I don't upload any of it by default. I hope you enjoyed this section.

Also, also, please if you could like the posts. It's surprising how much they can help spread it around.

Sunday, November 22, 2015

Kerbal Space Program AAR, First Flight

Decided to do something different than my usual stuff, by making an AAR (After-Action Report) for KSP. For those unfamiliar with the format, it's basically a writeup of what happens with pictures and a bit of extra fluff put in. This will be my first time writing something like this, so any comments or criticisms are much appreciated. Please let me know what you think!

Today marks the first day for the Kerbal's glorious new space program lead by director Xeorm. For anyone unfamiliar with this glorious race, these are Kerbals:


They have but one interest known to us: to build a space program. If nothing else, they prove that rocket science's difficulty has been exaggerated.

Here is a photo of our great facilities:

Small buildings, roads going to nowhere, a dirt road for our aircraft to launch, and a launching pad far away from the everything else. At least they got one thing right. Each building here has a function and can be upgraded to be better at what it does, or provide new functionality. Unfortunately, upgrading costs money, which we don't have much of. Up on the top you can see our current funds, reputation, and how much Science! we have collected.

Money is collected by breaking records or completing contracts, and we use it to build our crafts and upgrade our buildings. Reputation is used to impress the ladies get better contracts, and Science! is used to research new parts. The small building farthest to the left lets us turn one resource into another,

Enough with the introductions! Let's get this thing started. First thing we want to do is earn some money by accepting some contracts. Our first contract:

A very simple contract indeed, almost depressingly simple. Well, all journeys must start with a simple step, and this is ours. While we're at it, we grab the other contract:

When we launch our first rocket, they want us to grab some Science! from Kerbin. These guys really have some high expectations. I'm not sure we'll be able to do this.

Now that we have our goals, the next step is our design. We step into the Vehicle Assembly Building and I'm greeted with the plethora of options available to me. After a bit of tweaking, I've put together a functional rocket:

We use a model rocket someone bought at the store, we fill some canisters with strange goo found in the dumpster for Science!, a well-built command pod, and a parachute on top. We would have used a real rocket, but the Kerbals were too busy making things comfortable to worry about the actual rocket part of the program. Onwards to the first launch!

Here we are, on the launchpad, for our first ever rocket launch! Before we launch, we want to perform an experiment. Experiments are the main way we get Science!. We do an activity, at a location, and can choose to keep it, or send the information back. In this case, we've open our goo canister while landed at the launch pad, and we'll choose to keep it. Assuming the module is recovered successfully, we'll get our Science!


Off we go! We have liftoff. Our first rocket is in the air! Our rocket reaches a truly majestic height of 5,000 km. Only 65,000 km more to go and we'll officially be a space program! Until we're able to reach orbit though, all things that go up must come down.


Our pilot, after his successful landing, takes a stroll out in the open air. He doesn't seem to understand the gravity of the situation though, and gives us some lip. Just for that, we'll find some other pilot to fly the next rocket, when we get into actual space.

Finally, here's the mission report:


We made a decent amount of Science! from the trip, along with a good chunk of change. Turns out, there's a number of organizations that give out good money for achieving World Firsts, which is where the bulk of our money from this mission came from. Next mission should be more exciting, as we develop actual rockets and get into space. None of this amateur model rocket crap.

PS: For anyone interested, here's the difficulty settings I'm using for this run;
Hard settings, but with quickloading enabled to save my sanity.

Sunday, November 8, 2015

What is Coding?

A friend had a request: to answer the question "What is coding?" This post is here to answer that question. The pedantic answer is that coding is the act of writing code. Which doesn't answer much, aside from creating the question "Then what is code?".  Code is a set of instructions for computers or programs to run. Think of a cooking recipe, but for computers. The computer runs the code step by step, and it's this code that enables our computers to be as useful as they are.

At its heart, a computer has a very simple instruction set, from which we can do very complicated things. After all, a computer is little more than a calculator. Most of the functions it can do consist of reading and writing memory, performing simple boolean math, and perform actions based on comparisons. Getting something useful out of that requires clever usage of numbers, or using lots of simple actions to create something much more complex. Displaying an image on the screen, for example, involves writing the color value of each pixel in memory. Clever, but simple use of numbers to create something useful.

While the process of coding involves creating those simple instructions for the computer to read, almost all actual coding is done using higher level language that then creates the simpler code. The more control I want over what actually happens, the closer the code becomes to machine language. Usually though, it's simple and quicker to write code the further away from machine language it gets. This means in part that some code can look like I'm writing actual English, while lower level code will look like I'm writing gibberish. For example, see if you can understand this:

Console.WriteLine("Please enter your age:");
int age = Console.ReadLine();
if (age > 18)
{
              Console.WriteLine("Enjoy your drink!");
}
else
{
              Console.WriteLine("Here's some milk for you kid.");
}

This is code that would actually work in a program, to do what you think it does. A simple console prompt, enter a number, and output a sentence based on what you wrote. The code itself makes heavy use of functions in order to reuse code and make for easier to read code. If you want, think of the recipe example from earlier. When it tells you to preheat the oven, does it tell you how to preheat the oven? No, it tells you the relevant command (Preheat the oven) and gives you an relevant data in order to follow that command (the temp to set it at). Functions work similarly in code. Here, WriteLine is a function that prints the input, the stuff within the parentheses. Easy, simple, and an example of how coding becomes easier as time goes on and people add on shared functions.

There's a whole slew of other coding strategies that are used to save time and make the job easier, but I wanted to give at least one simple example, but won't go into more depth. But coding itself may look different based on which language you're using. This type makes hefty use of brackets in order to split code. Another that I'm familiar with uses parentheses for everything, while another uses tabs as part of the actual code. Another requires as part of the code that each line starts with a number, and that each number increases in value from one step to the next. They all look different, but each involve writing out instructions in order for the computer to run something more complex. This is coding.

Perhaps you might also want to know what coding is, by looking at what is not coding. A markup language like HTML is not coding. While it has some crazy symbols that we don't normally use in our language like "<", this does not make it coding. There's no series of instructions in an html page. Instead, a page consists of content, where it is marked up in a way to indicate to the computer how things should look. A CSS style sheet is similar, and involves a computer merging a given html page with the information in a CSS style sheet in order to determine how things work. Again, no series of instructions, but content.

Wednesday, October 7, 2015

Rockets in KSP

For something different this time, lets have some pictures. All pictures come from the game "Kerbal Space Program", a game I'd heartily recommend to anyone. For anyone not familiar with the game, it simulates a rocket program on the fictional planet Kerbin, where little green men called Kerbals conduct missions into space. It is not a game that takes itself seriously, but it does treat the science behind rocketry very seriously.

Kerbin itself is a bit smaller than Earth, with a solar system that's similar but with different distances and sizes. Because the hope here is to show in obvious terms how hard orbit is, and also how very expensive it is to send more stuff into space, the absolute difference in sizes should not matter; the relative differences should more than suffice.

I can't help seeing this and thinking "Missile"
We start off with the simplest craft imaginable. A crew pod, a heatshield, and a parachute, all on top of a single solid-fuel rocket. When talking about rockets, it's usually useful to split the rocket into two parts: the payload, and the rest of the rocket. Here, our payload is everything on top of the rocket, which all weighs 1.2t. (I'm assuming the measurement system is tons). The rocket itself weighs in at 3.56t, (the entire craft weighs 4.9t) with the fuel inside weighing 2.8 tons. For reference, this means 24% of the rocket is the stuff we want in space, 57% of it is fuel, and the remaining 19% is structural mass. Not too bad.
One guess as to what this rocket reminds me of
Next up, we have a craft that can get into orbit and come back down. In fact, it has a little extra fuel for emergencies/bad piloting, but not by much. You can see it has the same payload as the first, so 1.2t again is what we want in orbit. The rocket certainly increased in size though; it in total now weighs 20.3t; the entire craft is four times bigger to get something into orbit, rather than  getting it up into space. If anyone ever asks, remember that the hard part is going fast enough to get into orbit, not getting high enough.

Our rocket now has two stages; a bottom stage with three of the same solid-fuel rockets we used in the original rocket, and a second liquid-fuel rocket stage. For reference: the first stage weighs 10.68t, with 8.4t of that being solid fuel. The second stage weighs 8.25t, 6.3t of which is fuel and oxygen. All told, our rocket is now 6% what we want, 72% fuel, and 22% structure mass for the rocket. If you're thinking that this looks like a bad ratio between fuel to everything else, think again. This is actually fairly normal. Rocketry equations are crazy.

This is the only design that makes me think "Real Rocket"

Like the first craft I showed, this one is built only to get to orbital height, but not into actual orbit. Like the first, it also doesn't reach high enough, but the two are close enough to compare. The payload this time weighs in at 5.9t, or about 5 times heavier. Underneath are 7 of the same solid-fuel rocket, weighing 24.92t, with 19.6t spent on fuel. The entire craft weighs 31.4t, and the readout involves 19% payload, 62% fuel, and 17% structure. Note the fun part here: we have a rocket substantially bigger than the first, with a much larger payload, but the ratios are all relatively similar. Given the variance between which heights they reach and how air resistance factors in, these are really rather similar. But will the same occur with an orbital variant?

While I'd rather have all the rockets at the bottom, it was too unstable

Here's the same payload, but with enough rocket to put it into orbit and come back again. The craft weighs at 99.8t, with the same 5.9t spent on payload. It has 2 stages, one of 15 solid fuel rockets, at 53.4t, and a second liquid fuel stage of 39t. The percentages this time are: 6% payload, 74% fuel, and 20% structural. Unsurprisingly, the ratios are similar to the first orbital rocket! 

Even though we had a much larger payload, and a much larger rocket going up, the percentages remained similar. Why? The Tsiolkovsky Rocket Equation. The delta-v required for a given mission will be similar between rockets of various sizes. Assuming they use similar rocket types, they'll have similar exhaust velocities, and so their mass ratios will be similar as well.

Final notes: For anyone familiar with the game, yes, you could make rockets that were likely better than these. I was deliberately attempting to make rockets that behaved similarly to each other, which mandated some inefficiencies. I also used the scientifically less accurate term "weighs" instead of masses, because it sounds better conversationally. Outside of science, one does not refer to mass, they refer to weight, and the word "massive" especially is terrible for conversation. And if you have any questions or comments, please do leave a comment here, and I'll get to it shortly.