Null's Math Problem for 6 Months

that shouldnt be to complex, but i have no idea how to find the right formula...



thats more complex than needed, the change in pressure should be the main factor.



what? im pretty sure thats wrong. or you mean chlorine concentration, not pressure...

we dont need that, the pressure difference is the main factor.
Navier-stokes is the right equation to look for, but i have no idea how to get the right formula for our problem.

I was referring to chlorine concentration.

Navier-Stokes solves for an unknown velocity field of a fluid. This is useful for convective flow, but again, I assumed diffusion only.

To get a good estimate of pressure, use the data I provided along with an equation of state (ideal gas law, Redlich-Kwong, Peng-Robinson etc.). Ideal gas law is by far the easiest here because there are multiple gases.
Is there a fluid dynamics software that you'd recommend which is reasonably beginner friendly + doesn't cost multiple arms and legs?

Consider Simscale.com. It has somewhat limited mass transfer capabilities, but great as a free option for fluid dynamics. You do have to run the simulation on a cloud server which is really fucking annoying, but it has a very easy to use interface.

In my simulation I want things to move enough that people are able to work with gasses in real time. Before I had it so that the adjacent cubes would interact with each other as quickly as possible (i.e. a cube and its 6 adjacent neighbors would equalize 30 times per second, or as fast as the framerate could allow), which works, but then you have an issue where something is added to the air and then suddenly the room is just completely contaminated before you can even react.

I'm really trying to keep things simple, so I'm reluctant to say "okay I need to keep track of kinetic energy in each cube as well" - especially because there are going to be tens of thousands of these if things get bigger.

In SS13, I think gas just spreads at a fixed rate, which creates odd situations where a hull breach leaves only the neighboring tiles in an 8 block radius low pressure and things like 1 tile wide doorways effectively halt depressurization for 10 minutes before it spreads out of that room.
There are a couple of options here. The equilibration rate should increase with increasing concentrations of gas (which will result in a higher starting pressure in Box B), so you could increase the chlorine concentration. Convection can also be added (windows, fans etc). I apologize if this isn't helpful.
 
  • Informative
Reactions: Bongocat
How much more complicated is the math when you add in simple airflow? like if a 3x3x3 space is broken up into 27 cubes, how easy is calculating the convections of that room if there's a in and out vent port?
I can give it a shot. Can you re-draw the figure with the location of the inlet and outlet, along with it's dimensions (if its a circle, the radius/diameter is fine) and the inlet air speed and composition? I will have to make some assumptions about the fluid viscosity, density etc.
 
I can give it a shot. Can you re-draw the figure with the location of the inlet and outlet, along with it's dimensions (if its a circle, the radius/diameter is fine) and the inlet air speed and composition? I will have to make some assumptions about the fluid viscosity, density etc.
Don't think of it like that.

1607907874070.png


It's a grid. 3x3. Each tile is 1x1x3, with 3 cubes of atmosphere per meter, so 27 per tile, 243 for the entire room. The input vent top-right adds air to the bottom 9 cubes of the 3x3x9 stack. The input on the bottom left removes them by pulling down. Do not account for radius, just do cubes.

How complicated is the math for dealing with kinetic force with gasses with this kind of set up?
 
  • Informative
Reactions: Fromtheblackdepths
Don't think of it like that.

View attachment 1786767

It's a grid. 3x3. Each tile is 1x1x3, with 3 cubes of atmosphere per meter, so 27 per tile, 243 for the entire room. The input vent top-right adds air to the bottom 9 cubes of the 3x3x9 stack. The input on the bottom left removes them by pulling down. Do not account for radius, just do cubes.

How complicated is the math for dealing with kinetic force with gasses with this kind of set up?
I am a little confused by the "3 cubes of atmosphere per meter"

The math here (at least the numerical calculations) are not difficult, especially if it can be reduced to a 2D problem. I can create a 3x3 sketch, and consider the cube in the top right to be the inflow and the bottom left cube to be the outflow. Would this be satisfactory?
 
How much more complicated is the math when you add in simple airflow? like if a 3x3x3 space is broken up into 27 cubes, how easy is calculating the convections of that room if there's a in and out vent port?
Honestly if you aren't looking to make a scientifically accurate simulator just play around with formulas until you get something that feels right and is fun.
 
I am a little confused by the "3 cubes of atmosphere per meter"

The math here (at least the numerical calculations) are not difficult, especially if it can be reduced to a 2D problem. I can create a 3x3 sketch, and consider the cube in the top right to be the inflow and the bottom left cube to be the outflow. Would this be satisfactory?
It's more than 2D.

Imagine a rubicks cube that is 1m^3. Each cube component of this (the 9 individual cubes that make up a rubicks cube) is a 'gas jar' that represents a part of the atmosphere for the purposes of the simulation. A tile 1m wide and 3m tall, so imagine 3 of those rubicks cubes on top of each other. That's the 27 atmosphere cubes that make up a single tile.

A room that is 3x3 has 9 of these tiles, with 27 atmosphere cubes each, so that 3x3 room has 81 atmosphere cubes that are diffusing into each other. If I add kinetic force to gas, then they also have to deal with direction and force.
 
  • Informative
Reactions: Fromtheblackdepths
To get a good estimate of pressure, use the data I provided along with an equation of state (ideal gas law, Redlich-Kwong, Peng-Robinson etc.). Ideal gas law is by far the easiest here because there are multiple gases.
yeah i have no idea how to do that...
i can get to the pressure difference by using the ideal gas law and i can get to the new pressure after mixing, but i have no idea how to get the speed of the mixing.

In my simulation I want things to move enough that people are able to work with gasses in real time. Before I had it so that the adjacent cubes would interact with each other as quickly as possible (i.e. a cube and its 6 adjacent neighbors would equalize 30 times per second, or as fast as the framerate could allow), which works, but then you have an issue where something is added to the air and then suddenly the room is just completely contaminated before you can even react.
you should focus on the pressure differences.
you can solve your added gas problem with it.

How complicated is the math for dealing with kinetic force with gasses?
yes

A room that is 3x3 has 9 of these tiles, with 27 atmosphere cubes each, so that 3x3 room has 81 atmosphere cubes that are diffusing into each other. If I add kinetic force to gas, then they also have to deal with direction and force.
that will kill the framerate pretty fast^^

just play with a formula for pressure differences till you are happy with it and than use that formula for each gas in the mix.
 
  • Like
Reactions: Yotsubaaa
It's more than 2D.

Imagine a rubicks cube that is 1m^3. Each cube component of this (the 9 individual cubes that make up a rubicks cube) is a 'gas jar' that represents a part of the atmosphere for the purposes of the simulation. A tile 1m wide and 3m tall, so imagine 3 of those rubicks cubes on top of each other. That's the 27 atmosphere cubes that make up a single tile.

A room that is 3x3 has 9 of these tiles, with 27 atmosphere cubes each, so that 3x3 room has 81 atmosphere cubes that are diffusing into each other. If I add kinetic force to gas, then they also have to deal with direction and force.
So how I am interpreting this is one component is a rubix cube of 3x1x1 boxes like so

1607910146491.png


I may have to fuse some of the boxes to simplify the calculation, but this could work.
 
The important bits of information are 1 mol chlorine gas at 40°C in one cubic meter. The other gases, 1:5 mol O2:N2 (essentially air) are of the same composition thus can be ignored. Any pressure differential present should be accounted for by the one dissimilar gas - chlorine - as it diffuses into the new system.

First we need to do conversions and note known values:
T = 40°C = 313.15K
VCl= 1 m^3
VSystem= 2 m^3
N (Avagadro's Number) = 6.02 × 10^23 1/mol
k (Boltzmann's Constant)= 1.38066 x 10^-23 J/K

Looking at the PV=NkT form of the Ideal Gas Law and our knowns we can now see that pressure (P) is unknown. Using basic algebra we can solve for P.

P=(NkT)/V
As V=1m^3 it can be ignored in calculation (dividing by one equals the numerator; retain a token 1/m^3 for unit conversion) thus:
P=NkT
Now put in the rest of the known values:
P= (6.02 × 10^23 1/mol) * (1.38066 x 10^-23 J/K) * (313.15K)
We get 2601.64 J/mol/m^3. As we have one mole of chlorine, this rectifies to 2601.64J/m^3 or 2601.64 Pa (0.026 atm).

This would be the head pressure (for lack of a better term) of the chlorine in System B as it interfaces with System A through a 1 m^2 aperture.

I was no math whiz in school and it's been a while since I took physics, so please feel free to correct me if I botched the math or process.
 
Last edited:
you also should use some way to not calculate everything at the same time...

check difference of every even cube row with the row above it in one frame, than with with the row below in the next frame, same for the sides.
its not perfect but should help with performance.

cube 1 2
pressure gas a100100
pressure gas b100
total pressure 110100

the next step is to find a formula to use for the change in pressure. lets say change the difference by 1 every tick so new the we have(thats not the formula you should use!)

cube12
pressure gas a100100
pressure gas b91
total pressure109101

you can use that system for mixtures of gas AND for pressure.
 
you also should use some way to not calculate everything at the same time...

check difference of every even cube row with the row above it in one frame, than with with the row below in the next frame, same for the sides.
its not perfect but should help with performance.

cube12
pressure gas a100100
pressure gas b100
total pressure110100

the next step is to find a formula to use for the change in pressure. lets say change the difference by 1 every tick so new the we have(thats not the formula you should use!)

cube12
pressure gas a100100
pressure gas b91
total pressure109101

you can use that system for mixtures of gas AND for pressure.
The real shitbitch with fluid dynamics solvers is numerical stability. I wouldn't attempt to try to wing that... they have a tendency to explode really easily and at unpredictable times when kinetic forces get involved.
 
  • Semper Fidelis
Reactions: Yotsubaaa
The real shitbitch with fluid dynamics solvers is numerical stability. I wouldn't attempt to try to wing that... they have a tendency to explode really easily and at unpredictable times.
thats why he should do it as simple as possible, it just has to feel good and fit what people think is real(very few people have a clear idea how it works in reality so matching the feel is more important),
the change by 1 was just an example to make things easyer to understand, it should be a bit more complex than that.
 
thats why he should do it as simple as possible, it just has to feel good and fit what people think is real(very few people have a clear idea how it works in reality so matching the feel is more important),
the change by 1 was just an example to make things easyer to understand, it should be a bit more complex than that.
Yeah, the problem I'm struggling with here is that I don't know exactly how interactive these gasses need to be. There's talk of kinetic forces, but that simulation resolution is so low that they probably can't do anything interesting. At that kind of granularity, really all you can do is slowly move gasses as a block in a particular direction with wind force.

If that's the case, why bother with a real simulation at all? Why not just precompute some movement paths and blend between them for different airflow directions? That would be dirt cheap to run in realtime and would give you roughly the same result.
 
  • Winner
Reactions: Yotsubaaa
thats why he should do it as simple as possible, it just has to feel good and fit what people think is real(very few people have a clear idea how it works in reality so matching the feel is more important),
the change by 1 was just an example to make things easyer to understand, it should be a bit more complex than that.
Science is best described as the process by which lazy mathematicians winnow away complexity from a system until they are left with an easily digestible "good enough" model.
Unless it's absolutely necessary, simple systems work best. Using Dear Feeder's 6 Month Question, why bother modeling and calculating out every vortex and turbulence in this system instead of presuming basic diffusion in one direction? The flow regieme is never specified and the presented total system is alread textbook simple, why needlessly complicate it? Null wants to put two cubes together and know how fast the chlorine in one takes to fill the conjoined system.
 
  • Winner
Reactions: Yotsubaaa
Yeah, the problem I'm struggling with here is that I don't know exactly how interactive these gasses need to be. There's talk of kinetic forces, but that simulation resolution is so low that they probably can't do anything interesting. At that kind of granularity, really all you can do is slowly move gasses as a block in a particular direction with wind force.
thats why pressure is so elegant, it solves most problems well enough.
you need the ideal gas law and some good enough model for the change in pressure over time.

@Bob Chipman's Podiatrist do you have some idea what formula to use for the speed of pressure change between 2 cubes?

Using Dear Feeder's 6 Month Question, why bother modeling and calculating out every vortex and turbulence in this system instead of presuming basic diffusion in one direction?
from high to low pressure. you can even use it as basis for some weather model if you go big enough.
 
  • Like
Reactions: Mr. Skeltal
Back