[TRNSYS-users] if elseif else statement in equations
Jeff Thornton
thornton at tess-inc.com
Thu Apr 7 06:49:16 PDT 2022
Jan,
Yes it is possible but before you go down that route it’s important to understand if your variable T is impacted by the result of X. If T is the ambient temperature for example then X doesn’t affect it and you can use equations. If T is the temperature in a piping network and X is the flow rate then using equations will likely cause convergence errors and you are better off using differential controllers.
But if we assume that T isn’t affected by X then we simply use Boolean equations
X1 = LT(T,5)
X2 = GE(T,5)*LT(T,15)
X3 = GE(T,15)
X = X1*1 + X2*2 + X3*3
Jeff
Sent from my iPhone
> On Apr 7, 2022, at 7:00 AM, Böttner, Jan via TRNSYS-users <trnsys-users at lists.onebuilding.org> wrote:
>
>
> Hey everyone,
>
> i found this entry about implementing if else statements: http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/2013-February/024732.html
>
> I’m wondering if ist possible to extend this to an if elseif else statement.
>
> I want the output X to be X=1 if the temperature is t<5, X=2 for t>=5.and.t<15 and X=3 for t>=15.
>
> I tried this, but it’s wrong and doesnt work:
> X = GT(T,GT(T,15)*S+(1-GT(T,15))*U)*U+(1-GT(T,5))*W with S=3,U=2and W=1.
>
> If anyone knows a solution i’d appreciate it.
>
> Best regards
> Jan
> _______________________________________________
> TRNSYS-users mailing list
> TRNSYS-users at lists.onebuilding.org
> http://lists.onebuilding.org/listinfo.cgi/trnsys-users-onebuilding.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/attachments/20220407/7d6f571e/attachment.htm>
More information about the TRNSYS-users
mailing list