Jump to content

Special:Badtitle/NS90:User talk:Plumbium/Fluid-Physics-Example-How-To: Difference between revisions

From KDE UserBase Wiki
Plumbium (talk | contribs)
No edit summary
Plumbium (talk | contribs)
No edit summary
Line 62: Line 62:
Or write some functions if we want to repeat the calculation:
Or write some functions if we want to repeat the calculation:
{{Input |<nowiki>finalTempFromKelvins2:=(c1,v1,t1,c2,v2,t2)->(c1*v1*t1 + c2*v2*t2)/(c1*v1+c2*v2)
{{Input |<nowiki>finalTempFromKelvins2:=(c1,v1,t1,c2,v2,t2)->(c1*v1*t1 + c2*v2*t2)/(c1*v1+c2*v2)
finalTempFromCelsius2:=(c1,v1,t1,c2,v2,t2)->finalTempFromKelvins(c1,v1,celsiusToKelvins(t1),c2,v2,celsiusToKelvins(t2))
finalTempFromCelsius2:=(c1,v1,t1,c2,v2,t2)->finalTempFromKelvins2(c1,v1,celsiusToKelvins(t1),c2,v2,celsiusToKelvins(t2))
finalTempFromFahr2:=(c1,v1,t1,c2,v2,t2)->finalTempFromKelvins(c1,v1,fahrenheitToKelvins(t1),c2,v2,fahrenheitToKelvins(t2))
finalTempFromFahr2:=(c1,v1,t1,c2,v2,t2)->finalTempFromKelvins2(c1,v1,fahrenheitToKelvins(t1),c2,v2,fahrenheitToKelvins(t2))
</nowiki>}}
</nowiki>}}

Revision as of 04:34, 31 December 2010

Under Construction

This is a new page, currently under construction!


This page shows how to use KAlgebra to solve problems such as the following: Given the properties of two different liquids, what will be the temperature of the resulting mixture?

Converting to Kelvins

Thermodynamics equations tend to work much better in Kelvins, so first we need to write a couple of functions, celsiusToKelvins and fahrenheitToKelvins, to deal with Celsius and Fahrenheit Degrees, as well as another function, fahrenheitToCelsius, which will make it easier to write fahrenheitToKelvins.

The formulas for these conversions are:
C = (F - 32) / (1.8) and K = C + 273.15

and the corresponding functions:

celsiusToKelvins:=temp-&gt;temp+273.15
fahrenheitToCelsius:=temp-&gt;(temp-32)/1.8
fahrenheitToKelvins:=temp-&gt;celsiusToKelvins(fahrenheitToCelsius(temp))

(in fahrenheitToKelvins, we first convert to Celsius calling fahrenheitToCelsius, and then convert to Kelvins using fahrenheitToKelvins)

Example Problem with Same Material, but Different Volumes and Temperatures

Now, what if we need to know the final temperature when we mix 40L of 15°C water with 30L of 70°C water? Using conservation of energy, we know that the initial and final thermal energies are the same, so the final energy is equal to the energy of the first fluid plus the energy of the second fluid(using U for internal energy):
U(final) = U1 + U2

Internal energy is equal to the volumetric heat capacity times volume times temperature(in Kelvins):
U = C*V*T

So C(final)*V(final)*T(final) = C1*V1*T1 + C2*V2*T2

And since the heat capacities are all the same and cancel out, and the final volume is the sum of the two initial volumes: (V1+V2)*T(final) = V1*T1 + V2*T2
or
T(final) = (V1*T1 + V2*T2)/(V1+V2)

We can then either use this directly in KAlgebra:

(40*celsiusToKelvins(15) + 30*celsiusToKelvins(70))/(40 + 30)
=    311.721

and get the final temperature(in Kelvins), or put in these functions if we need to repeat the computation:

finalTempFromKelvins:=(v1,t1,v2,t2)-&gt;(v1*t1 + v2*t2)/(v1+v2)
finalTempFromCelsius:=(v1,t1,v2,t2)-&gt;finalTempFromKelvins(v1,celsiusToKelvins(t1),v2,celsiusToKelvins(t2))
finalTempFromFahr:=(v1,t1,v2,t2)-&gt;finalTempFromKelvins(v1,fahrenheitToKelvins(t1),v2,fahrenheitToKelvins(t2))

Example Problem with Different Fluids

Now, suppose the two fluids have different volumetric heat capacities, such as 4180 J/(L*K) for the first liquid(water), and 1925 J/(L*K) for the second liquid(ethanol). We will need to refer back to the equation:
C(final)*V(final)*T(final) = C1*V1*T1 + C2*V2*T2

The resultant heat capacity will be the average of the capacities of the first and second fluids, weighted by volume(since it is a volumetric heat capacity rather than mass- or molar-specific):
C(final) = (C1*V1 + C2*V2)/V(final)

And plugging this into the previous equation, we get:
(C1*V1 + C2*V2)*T(final) = C1*V1*T1 + C2*V2*T2
or
T(final) = (C1*V1*T1 + C2*V2*T2)/(C1*V1 + C2*V2)

And either use this formula directly:

((4,180*40)*celsiusToKelvins(15) + (1,925*30)*celsiusToKelvins(70))/(4,180*40+1,925*30)
=    302.27

Or write some functions if we want to repeat the calculation:

finalTempFromKelvins2:=(c1,v1,t1,c2,v2,t2)-&gt;(c1*v1*t1 + c2*v2*t2)/(c1*v1+c2*v2)
finalTempFromCelsius2:=(c1,v1,t1,c2,v2,t2)-&gt;finalTempFromKelvins2(c1,v1,celsiusToKelvins(t1),c2,v2,celsiusToKelvins(t2))
finalTempFromFahr2:=(c1,v1,t1,c2,v2,t2)-&gt;finalTempFromKelvins2(c1,v1,fahrenheitToKelvins(t1),c2,v2,fahrenheitToKelvins(t2))