As usual, LitDev has concocted some great November challenges, based on ideas from the Small Basic community!
Today we're going to focus on a Physics Challenge that's challenging even to think about... The Difficult Gas Challenge!
Welcome to the monthly Small Basic Challenge!
These challenges are intended for people who are learning to program for the first time or for those returning to programming who want to start using SmallBasic. Some will be easy, some will be hard - but they will all make you think, and more importantly be GREAT FUN!
Please post your solutions / partial solutions / questions / feedback etc. into this thread that will remain 'sticky' for the month. The only rule is that your solution must use standard Small Basic methods (no extensions).
Running out of simple physics challenges - this one isn't much harder, just takes more explaining.
An ideal gas has the following equation relating its pressure (P Bars), volume (V litres) and temperature (T degC). http://en.wikipedia.org/wiki/Ideal_gas
(1) P * V / (273 + T) = constantA (ideal gas equation)
This means that if we know the starting state (P, V & T) and any 2 quantities are changed then the 3rd can be calculated.
If we start at P = 2 Bar, V = 1 litre and T = 20 C and change the pressure, volume or temperature, then the others will change to keep the equation equal to constantA.
For example if we keep the temperature constant and double the volume, then the pressure will half (Boyle’s Law).
If there is no heat transfer (or technically no entropy change), then the following equation also holds for gases. https://en.wikipedia.org/wiki/Isentropic_process
(2) P * V^g = constantB (isentropic or adiabatic expansion)
g is a property of the gas (isentropic exponent), for air it is about 1.4.
V^g means V to the power of g; in SmallBasic this is Math.Power(V, g). If you don’t know about powers then use P * V * V = constantB.
If we know the starting pressure and volume, then we can calculate the change in either P or V if the other is changed.
An example of gas compression heating a gas is the warming of a bicycle pump, and gas expansion cooling a gas might be ice that forms on the nozzle when a CO2 fire extinguisher is used, or even how a fridge works.
So if the volume changes, then the pressure will change according to (eqn 2) and the resulting pressure and volume change lead to a change in temperature (eqn 1).
Calculate and perhaps plot the change in temperature and pressure as we increase (expand) or decrease (compress) the gas volume.
Hint: Equations 1 and 2 can be written to show how the initial and new values of P,V,T are related:
(273 + T2) / (P2 * V2) = (273 + T1) / (P1 * V1)P2 = P1 * (V1/V2)^gwhere P1,V1,T1 are initial values and P2,V2,V2 are new values.
How much must we expand 1 litre of air to cool it from 20C to 0C? What is the pressure change if we start at 2 Bar?
Not a programming question, but would it take more or less or similar effort pump up a cycle tire on a hot or cold day?
Join this challenge here: Challenge of the Month - November 2012
- Tall Basic Ed