Skip to content

Commit

Permalink
save Zs(Rs) value in a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Yujie Xu committed Sep 12, 2024
1 parent b23f9ad commit bd97716
Showing 1 changed file with 34 additions and 26 deletions.
60 changes: 34 additions & 26 deletions src/EnergyPlus/ExtendedHI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ namespace ExtendedHI {
Real64 phi = 0.84;
Real64 Pa = RH * pvstar(Ta);
Real64 Rs = 0.0387;
Real64 m = (Pc - Pa) / (Zs(Rs) + Za);
Real64 ZsRs = Zs(Rs);
Real64 m = (Pc - Pa) / (ZsRs + Za);
Real64 Ts;
int SolFla;
General::SolveRoot(
Expand All @@ -180,7 +181,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Ts,
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (Zs(Rs) + Za) - (Tc - Ts) / Rs; },
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (ZsRs + Za) - (Tc - Ts) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m)),
std::max(Tc, Ta) + Rs * std::abs(m));
Real64 flux1 = Q - Qv(Ta, Pa) - (1.0 - phi) * (Tc - Ts) / Rs;
Expand All @@ -195,8 +196,9 @@ namespace ExtendedHI {
Real64 Pa = RH * pvstar(Ta);
Real64 Rs = 0.0387;
Real64 phi = 0.84;
Real64 m_bar = (Pc - Pa) / (Zs(Rs) + Za_bar);
Real64 m = (Pc - Pa) / (Zs(Rs) + Za);
Real64 ZsRs = Zs(Rs);
Real64 m_bar = (Pc - Pa) / (ZsRs + Za_bar);
Real64 m = (Pc - Pa) / (ZsRs + Za);
Real64 Ts;
int SolFla;
General::SolveRoot(
Expand All @@ -205,7 +207,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Ts,
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (Zs(Rs) + Za) - (Tc - Ts) / Rs; },
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (ZsRs + Za) - (Tc - Ts) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m)),
std::max(Tc, Ta) + Rs * std::abs(m));
Real64 Tf;
Expand All @@ -215,7 +217,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Tf,
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (Zs(Rs) + Za_bar) - (Tc - Tf) / Rs; },
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (ZsRs + Za_bar) - (Tc - Tf) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m_bar)),
std::max(Tc, Ta) + Rs * std::abs(m_bar));
Real64 flux1 = Q - Qv(Ta, Pa) - (1.0 - phi) * (Tc - Ts) / Rs;
Expand All @@ -232,7 +234,7 @@ namespace ExtendedHI {
SolFla,
Tf,
[&](Real64 Tf) {
return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) * (Tf - Ta) / ((Zs(Rs) + Za_bar) * (Tf - Ta) + r * Ra_bar(Tf, Ta) * (Ts_bar - Tf)) -
return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) * (Tf - Ta) / ((ZsRs + Za_bar) * (Tf - Ta) + r * Ra_bar(Tf, Ta) * (Ts_bar - Tf)) -
(Tc - Ts_bar) / Rs;
},
Ta,
Expand All @@ -250,8 +252,9 @@ namespace ExtendedHI {
Real64 Pa = RH * pvstar(Ta);
Real64 phi = 0.84;
Real64 Rs = 0.0387;
Real64 m = (Pc - Pa) / (Zs(Rs) + Za);
Real64 m_bar = (Pc - Pa) / (Zs(Rs) + Za_bar);
Real64 ZsRs = Zs(Rs);
Real64 m = (Pc - Pa) / (ZsRs + Za);
Real64 m_bar = (Pc - Pa) / (ZsRs + Za_bar);
Real64 Ts;
int SolFla;
General::SolveRoot(
Expand All @@ -260,7 +263,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Ts,
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (Zs(Rs) + Za) - (Tc - Ts) / Rs; },
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (ZsRs + Za) - (Tc - Ts) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m)),
std::max(Tc, Ta) + Rs * std::abs(m));
Real64 Tf;
Expand All @@ -270,7 +273,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Tf,
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (Zs(Rs) + Za_bar) - (Tc - Tf) / Rs; },
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (ZsRs + Za_bar) - (Tc - Tf) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m_bar)),
std::max(Tc, Ta) + Rs * std::abs(m_bar));
Real64 flux1 = Q - Qv(Ta, Pa) - (1.0 - phi) * (Tc - Ts) / Rs;
Expand All @@ -288,7 +291,8 @@ namespace ExtendedHI {
0.0,
Tc);
Rs = (Tc - Ts) / (Q - Qv(Ta, Pa));
Real64 Ps = Pc - (Pc - Pa) * Zs(Rs) / (Zs(Rs) + Za_un);
ZsRs = Zs(Rs);
Real64 Ps = Pc - (Pc - Pa) * ZsRs / (ZsRs + Za_un);
if (Ps > phi_salt * pvstar(Ts)) {
General::SolveRoot(
state,
Expand All @@ -313,9 +317,10 @@ namespace ExtendedHI {
Real64 dTcdt = 0.0;
Real64 Pa = RH * pvstar(Ta);
Real64 Rs = 0.0387;
Real64 ZsRs = Zs(Rs);
Real64 phi = 0.84;
Real64 m = (Pc - Pa) / (Zs(Rs) + Za);
Real64 m_bar = (Pc - Pa) / (Zs(Rs) + Za_bar);
Real64 m = (Pc - Pa) / (ZsRs + Za);
Real64 m_bar = (Pc - Pa) / (ZsRs + Za_bar);
Real64 Ts;
int SolFla;
General::SolveRoot(
Expand All @@ -324,7 +329,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Ts,
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (Zs(Rs) + Za) - (Tc - Ts) / Rs; },
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (ZsRs + Za) - (Tc - Ts) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m)),
std::max(Tc, Ta) + Rs * std::abs(m));
Real64 Tf;
Expand All @@ -334,7 +339,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Tf,
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (Zs(Rs) + Za_bar) - (Tc - Tf) / Rs; },
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (ZsRs + Za_bar) - (Tc - Tf) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m_bar)),
std::max(Tc, Ta) + Rs * std::abs(m_bar));
Real64 flux1 = Q - Qv(Ta, Pa) - (1.0 - phi) * (Tc - Ts) / Rs;
Expand All @@ -351,9 +356,10 @@ namespace ExtendedHI {

Real64 Pa = RH * pvstar(Ta);
Real64 Rs = 0.0387;
Real64 ZsRs = Zs(Rs);
Real64 phi = 0.84;
Real64 m = (Pc - Pa) / (Zs(Rs) + Za);
Real64 m_bar = (Pc - Pa) / (Zs(Rs) + Za_bar);
Real64 m = (Pc - Pa) / (ZsRs + Za);
Real64 m_bar = (Pc - Pa) / (ZsRs + Za_bar);

int SolFla;
Real64 Ts;
Expand All @@ -363,7 +369,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Ts,
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (Zs(Rs) + Za) - (Tc - Ts) / Rs; },
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (ZsRs + Za) - (Tc - Ts) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m)),
std::max(Tc, Ta) + Rs * std::abs(m));

Expand All @@ -374,7 +380,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Tf,
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (Zs(Rs) + Za_bar) - (Tc - Tf) / Rs; },
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (ZsRs + Za_bar) - (Tc - Tf) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m_bar)),
std::max(Tc, Ta) + Rs * std::abs(m_bar));
Real64 flux1 = Q - Qv(Ta, Pa) - (1.0 - phi) * (Tc - Ts) / Rs;
Expand All @@ -401,8 +407,9 @@ namespace ExtendedHI {
Real64 Rs = 0.0387;
Real64 phi = 0.84;
Real64 dTcdt = 0.0;
Real64 m = (Pc - Pa) / (Zs(Rs) + Za);
Real64 m_bar = (Pc - Pa) / (Zs(Rs) + Za_bar);
Real64 ZsRs = Zs(Rs);
Real64 m = (Pc - Pa) / (ZsRs + Za);
Real64 m_bar = (Pc - Pa) / (ZsRs + Za_bar);

int SolFla;
Real64 Ts;
Expand All @@ -412,7 +419,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Ts,
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (Zs(Rs) + Za) - (Tc - Ts) / Rs; },
[&](Real64 Ts) { return (Ts - Ta) / Ra(Ts, Ta) + (Pc - Pa) / (ZsRs + Za) - (Tc - Ts) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m)),
std::max(Tc, Ta) + Rs * std::abs(m));

Expand All @@ -423,7 +430,7 @@ namespace ExtendedHI {
maxIter,
SolFla,
Tf,
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (Zs(Rs) + Za_bar) - (Tc - Tf) / Rs; },
[&](Real64 Tf) { return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) / (ZsRs + Za_bar) - (Tc - Tf) / Rs; },
std::max(0.0, std::min(Tc, Ta) - Rs * std::abs(m_bar)),
std::max(Tc, Ta) + Rs * std::abs(m_bar));
Real64 flux1 = Q - Qv(Ta, Pa) - (1.0 - phi) * (Tc - Ts) / Rs;
Expand All @@ -442,7 +449,7 @@ namespace ExtendedHI {
SolFla,
Tf,
[&](Real64 Tf) {
return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) * (Tf - Ta) / ((Zs(Rs) + Za_bar) * (Tf - Ta) + r * Ra_bar(Tf, Ta) * (Ts_bar - Tf)) -
return (Tf - Ta) / Ra_bar(Tf, Ta) + (Pc - Pa) * (Tf - Ta) / ((ZsRs + Za_bar) * (Tf - Ta) + r * Ra_bar(Tf, Ta) * (Ts_bar - Tf)) -
(Tc - Ts_bar) / Rs;
},
Ta,
Expand All @@ -462,7 +469,8 @@ namespace ExtendedHI {
0.0,
Tc);
Rs = (Tc - Ts) / (Q - Qv(Ta, Pa));
Real64 Ps = Pc - (Pc - Pa) * Zs(Rs) / (Zs(Rs) + Za_un);
ZsRs = Zs(Rs);
Real64 Ps = Pc - (Pc - Pa) * ZsRs / (ZsRs + Za_un);
if (Ps > phi_salt * pvstar(Ts)) {
General::SolveRoot(
state,
Expand Down

0 comments on commit bd97716

Please sign in to comment.