# Fluid-Physics-Example-How-To

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?

## 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:
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*15 + 30*70)/(40 + 30)
```
```(40*15+30*70)/(40+30)
=38.5714```

and get the final temperature, or put in a function if we need to repeat the computation:

`finalTemp:=(v1,t1,v2,t2)->(v1*t1 + v2*t2)/(v1+v2)`

Which we can then use like this:

```finalTemp(40,15,30,70)
```
```finalTemp(40, 15, 30, 70)
=38.5714```

## 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:

```(4180*40*15 + 1925*30*70)/(4180*40+1925*30)
```
```((4,180*40)*15+(1,925*30)*70)/(4,180*40+1,925*30)
=29.1198```

Or write a function if we want to repeat the calculation:

```finalTemp2:=(c1,v1,t1,c2,v2,t2)->(c1*v1*t1 + c2*v2*t2)/(c1*v1+c2*v2)
```

Which we can then use like this:

```finalTemp2(4180,40,15,1925,30,70)
```
```finalTemp2(4,180, 40, 15, 1,925, 30, 70)
=29.1198```

Screenshot of KAlgebra after running these computations:

Plumbium08:01, 30 December 2010
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal