Carefully controlled explosions

Begin: LogEntry_0004
SolYear: 8760.85

In my previous log entry, I gave a rough idea on how I've done my gas box simulations, here I'm going to record it in more detail, so I can hopefully recreate it, should I lose it to the local, still weirdly aggressive, fauna.

I'm just going to quote from my last entry:

"I'm looking at an ideal gas, meaning I have no particle to particle interactions, I'm going to ignore the gravitational force on my particles, since it will be negligibly small over the duration of my simulation and in the environment this will be used in, I will also assume that when the particles hit the sides of my box, that the collisions will be perfectly elastic, meaning the kinetic energy of the particle is conserved, or put more simply, it bounces back with the same velocity it bounced into the wall.

Now, I can define my variables, I will use \(P\) as a variable for all the particle positions and \(V\) for all the particle velocities, given my definitions above my particle velocities won't change, so I won't need to deal with any particle acceleration."

I also set up a simply equation that I could solve, \(P_{n+1} = P_{n} + \big(V * dt \big)\), but I said I can't show this easily mathematically, I hope to do this now.

For every timestep, I will take a look at my newly calculated \(P_{n+1}\), and for every particle I will look at whether they are outside the box. Remember that my positions \(P\) contains information about all my particles, specifically their positions in the \(x\)\(y\) and \(z\) spatial directions, so when I now write the logic statement \(P_{n+1} > L\), where L is the lengths of the sides of my box, this should give me a new variable, which I will call \(B\)(for boolean).

In this new \(B\) variable I still have information about my particles, still in the \(x\)\(y\) and \(z\) spatial directions, it's just that now they're not numbers representing their position in these spatial directions, now they're True/False depending on whether the number in \(P_{n+1}\) is greater than \(L\). But what can I do with this information? Now I just know where they're outside the box, and in what spatial dimension.

Well, to make sure they go back inside the box, I need to turn them around in the relevant spatial direction, and I also need to do a correction of the particle's position to put it back inside the box. This might seem like a lot, but with the True/False results in \(B\), I can do all of this! 

So for every True value in \(B\) I go into the velocity variable \(V\) and turn the velocity around(multiply by \(-1\)), and then I can also correct every particle in \(P_{n+1}\) that is outside the box, to their correct positions inside the box, I basically take \(2L \) and then subtract the position of the particle outside the box, and set that as the particle's new position.

I can also use the values in \(B\) to count how many particles hit the wall, and how much momentum (\(p\)) that hit the wall, to then later calculate the pressure in the box. Since the pressure inside the box, is basically how much force the gas inside the box, applies to the box.

This is the basics to just simulate the box over time, and after having used lots and lots of paper to check that this was working, I moved on to introducing the nozzle.

To introduce the nozzle, I've introduced some new new variables named \(N\) for nozzle, \(N_x\)\(N_y\)\(N_z\) and \(N\). The variables in the \(x\)\(y\) and \(z\) spatial directions are combined into the one variable \(N\) using basic logic operations. The nozzle in this explanation is going to be set as a square with side lengths \(L_N\), placed on one of the box faces that is normal to the \(z\) axis. 

The variables \(N_x \) and \(N_y\) measure whether the particles are within the positions decided by \(L_N\), if I then do an \(and\) operation on these two variables, I will get a temporary variable \(N_{xy}\) which is True only in the positions where both \(N_x \) and \(N_y\) are True. 

The variable \(N_z\) measures whether the particles are outside one of the box faces normal to the \(z\) direction, so now I can do another \(and\) operation on \(N_z\) and \(N_{xy}\), giving me \(N\), which is now only True for particles that are outside the box on the right face, within the confines of the nozzle.

This final variable \(N\), can now be used to record the momentum in the \(z\) direction of the particles which are recorded as True. I only record the momentum in the \(z\) direction because this is the only momentum that will propel my box in the \(z\) direction. I will have momentum going in the \(x\) and \(y\) directions, but they should turn out to be a net zero, it is equally likely that a particle leaves momentum in the positive and negative \(x\) or \(y\) directions, so they should cancel out statistically.

Right, with these notes I should be able to recreate my work in case I lose it! 

I'd also like to write down how I figured out how to choose my variables like timestep length \(dt\), temperature \(T\), box side length \(L\), number of gas particles \(N\), and how long to run the simulation \(t\). At first I literally spent lots of time trying a few different, to my mind sensible, variable values, and after struggling to get sensible results, one of my robots came up to me unprompted with some suggestions. After implementing these suggestions, I started getting way more sensible calculations!

In some of my first attempts I had velocities that were so high, that during one timestep of length \(dt\) they moved distances that were 10s of times longer than the side lengths of my box! So one of the first things I worked out was whether the particles were moving that fast or not, and whether that could reasonably be fixed by taking shorter timesteps \(dt\) or not. I seem to have lost the exact program I used for this though, so I might have to remake that in the future.

Anywho, it was lots of experimentation, and checking whether my work was consistent with the analytical results that my variable choices led to.

Oh and finally I'd like to note, I'm going to do lots of experiments with the metals I'm going to construct my spacecraft from, so I can actually know how much it can take. If it turns out my calculated optimal pressure, is beyond what my construction techniques can take, I'll have to revisit this work and figure out what pressures can work.

End: LogEntry0004

 

Publisert 22. sep. 2021 18:08 - Sist endret 22. sep. 2021 22:30