#! /bin/zsh # # this file: # http://user.it.uu.se/~embe8573/conf/.zsh/air # https://dataswamp.org/~incal/conf/.zsh/air # # thanks bildramer at ##math, freenode: # the simplest way for 2D data is bilinear # interpolation: given that the next lowest data # point is (x0, y0) and the next highest is # (x1, y1) you calculate s = (x - x0)/(x1 - x0) and # t = (y - y0)/(y1 - y0). then the output is # (1 - s)((1 - t)f00 + t*f01) + s((1 - t)f10 + t*f11) # # Let's model an inflated bicycle tube/tire in the form of # a torus, as in this figure: [1] # # We use the ISO ETRTO notation for bicycle tire sizes. # For example, a typical 29-er MTB tire is 57-622, where 57 is # the tire width and 622 the rim BSD (Bead Seat Diameter) in # mm. See [2]. Let's denote the width w and the BSD b. # # Comparing [1] and [2], we understand that # # r = w/2 # # and # # R = b/2 + r # # R = b/2 + w/2 # # with the volume of a torus being # # V = 2 * pi^2 * R * r^2 # # V = 2 * pi^2 * (b/2 + w/2) * (w/2)^2 # # V = pi^2w(b+w^2)/4 # # Now let's put all that into a function to evermore do # the math for us: bike-tire-volume () { local width=\$1 local bsd=\$2 local pi=3.1415 local vmm=\$(( \$pi**2 * \$width * (\$bsd + \$width**2) / 4 )) local vcm=\$(units -t "\$vmm mm3" cm3) local rvcm=\$(( rint(\$vcm) )) printf "V = %d cm3\n" \$rvcm return \$rvcm } # Example invocation, our MTB 29-er: # # \$ bike-tire-volume 57 622 # \$ V = 544 cm3 # # Next step... # # We assume that air behaves like an ideal gas at reasonable # preassure levels with respect to bike tires, and at the # given temperature. That means we can use the ideal gas law, # PV = nRT (even tho air isn't an ideal gas, but it's close # enough for our purposes. [3]) # # Finally, we change the units into SI and then compute. # # SUMMARY # # The air, in mols, in a bicycle tire is # # n = Ppi^2w(b + w^2)/4RT # # where # # P is the air pressure (in liters; her inputted in psi) # w .. the tire width in mm # b .. the rim BSD (in mm) # R .. the gas constant, 0.0822 l-atm/mol-K # T .. the temperature, arbitrarily set to 290.45K (+17.3C) [4] # # Now we put everything together... bike-tire-air () { local width=\$1 local bsd=\$2 local psi=\$3 bike-tire-volume \$width \$bsd local vcm=\$? local p=\$(units -t "\$psi psi" atm) local v=\$(units -t "\$vcm cm3" liters) local t=290.45 local r=0.0821 local n=\$(( (\$p * \$v) / (\$r * \$t) )) printf "%f moles of air gas\n" \$n } # Here are some interesting results, all using common bicycle # tire/preassure configurations as indata. # # MTB 29-er: 57-622, 65 psi # \$ bike-tire-air 57 622 65 # \$ V = 544 cm3 # \$ 0.100902 moles of air gas # # road bike, tire at maximum psi: 23-622, 145 psi # \$ bike-tire-air 23 622 145 # \$ V = 65 cm3 # \$ 0.026895 moles of air gas # # we compare the road bike to the MTB: # (/ 0.026895 0.100902) ; 26% of MTB tire air in the road bike tire # # road bike, a realistic psi for a ~80 kg rider: 23-622, 115 psi # \$ bike-tire-air 23 622 115 # V = 65 cm3 # 0.021330 moles of air gas # (/ 0.021330 0.100902) ; 21% v MTB # # road bike: is it worth upgrading from 23 mm to 25 mm? # \$ bike-tire-air 23 622 115 # V = 65 cm3 # 0.021330 moles of air gas # \$ bike-tire-air 25 622 100 # V = 77 cm3 # 0.021972 moles of air gas # (- 100 (* 100 (/ 0.021330 0.021972))) ; only +2.9%! :O # so two new, expensive tires equals a mere (* 2 2.9) ; +5.8% # # some budget tires I have on a fixie # \$ bike-tire-air 28 622 85 # V = 97 cm3 # 0.023528 moles of air gas # (/ 0.023528 0.100902) ; 23% v. MTB # Also, that is only a +2% increase compared to the # 23 mm road tire which is supposedly 5 mm less wide. But this # may not be shocking tho given the steep drop from 115 # to 85 psi in air preassure. # # [1] https://www.mathsisfun.com/geometry/torus.html # # [2] https://dataswamp.org/~incal/bike/tire-size.png # # [3] In theory, air isn't an ideal gas. To compute # a meticulous result one would have to include Z, the air # compressibility factor: PV = nRTZ (for an ideal gas, # Z is 1 and thus falls from the equation). However, even # with air, at temperature T = 300 K (+27C) and preassure # P between 5-10 bar (73-145 psi), Z is between # 0.9974-0.9987. So for the purpose of this document air # is practically ideal. # # # # # [4] 290.45K or +17.3C is the average temperature in Liège in # July, the hottest month of the year. #