Hello,
Please forgive me because I've tried some of the methods but it still doesn't work for me. Or, I just misunderstand some of the explanations
This is the original code that was written and I receive the error for Cwater = 0.61..... cannot be used as a parameter because Cwater gain a fixed value.
(*Temperature of water*)
Twater = 300
Cwater = QuantityMagnitude[
ThermodynamicData["Water",
"ThermalConductivity", {"Temperature" ->
Quantity[Twater, "Kelvins"]}]]
ClassicalRungeKuttaCoefficients[4, prec_] :=
With[{amat = {{1/2}, {0, 1/2}, {0, 0, 1}},
bvec = {1/6, 1/3, 1/3, 1/6}, cvec = {1/2, 1/2, 1}},
N[{amat, bvec, cvec}, prec]];
f = ParametricNDSolveValue[{Derivative[1][y][x] ==
Piecewise[{{(y[x] + Cwater/3 x^3 + 3 z ),
0 <= x <= 1}, {(y[x] + Cwater/3 x^2 + 2 z),
1 <= x <= 2}, {(y[x] + Cwater/3 x + z), 2 <= x <= 3}}],
y[0] == 0}, y[3.], {x, 0., 3.}, {z, Cwater},
Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 4,
"Coefficients" -> ClassicalRungeKuttaCoefficients},
StartingStepSize -> 1/10];
FindRoot[f[z, Twater] == 100., {z, 1}, Evaluated -> False]
(*Tnew*)
170 + 2*z /. FindRoot[f[z, Twater] == 100., {z, 1}, Evaluated -> False]
(*Find eq.temp.*)
g = 170 + 2 z /.
FindRoot[f[z, #] == 100., {z, 1}, Evaluated -> False] &;
Teq = x /. FindRoot[g[x] == x, {x, Twater}, Evaluated -> False]
(*Check*)
170 + 2*z /. FindRoot[f[z, Teq] == 100., {z, 1}, Evaluated -> False]
Then I changed the command for Cwater by
Cwater = QuantityMagnitude[
ThermodynamicData["Water",
"ThermalConductivity", {"Temperature" ->
Quantity[#, "Kelvins"]}]] &;
(*eg:*)
Temp = Quantity[{t, 300, 360}, "Kelvins"]
And I received this error
ThermodynamicData::quants: List {t,300,360} does not consist of real numbers. >>
Shall I change into For loop with Temperature as i++ until 400 and stop when Tinitial = Tfinal?
How do I do that?