Presentation is loading. Please wait.

Presentation is loading. Please wait.

Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Procedures and Functions PROCEDURE TEST(A,B,C:X,Y)... X :=... Y :=... END.

Similar presentations


Presentation on theme: "Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Procedures and Functions PROCEDURE TEST(A,B,C:X,Y)... X :=... Y :=... END."— Presentation transcript:

1 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Procedures and Functions PROCEDURE TEST(A,B,C:X,Y)... X :=... Y :=... END Inputs Outputs CALL TEST(1,2,3:X,Y) Calling from main equation set: Functions and procedures must be placed before equations! FUNCTION Smallest(X,Y,Z) if (X<Y) then S:=X else S:=Y if (S<Z) then goto 10 S:=Z 10: Smallest:=S; END Inputs (only one output!) (Note that English EES notation has been used) x=smallest(1,2,3) Calling from main equation set: End-marker

2 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Loops and Logical Operators Repeat-Until j:=0 repeat j:=j+1; A[j]:=j+1 until (j>=1000) Logical (or comparison) operators (IF - THEN - ELSE or REPEAT – UNTIL): < (less than) > (greater than) = (equal) <= (less than or equal) >= (greater than or equal) and (logical and) or (logical or) IF-THEN-ELSE IF {logical expression} THEN {Operation} ELSE {Operation} Ex: IF (X 2) THEN A:=3 ELSE A:=X*Y (Within Procedures and Functions!)

3 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Logical Expressions in Equation Set ARG=IF(A, B, X, Y, Z) If A<B ARG=X If A=B ARG=Y If A>B ARG=Z Be cautious with discontinuities!!!

4 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen ”Loops” in the Equation Set The Duplicate Function: Duplicate j=1,5 A[j]=h[j]-T*s[j] End is equivalent to: A[1]=h[1]-T*s[1] A[2]=h[2]-T*s[2] A[3]=h[3]-T*s[3] A[4]=h[4]-T*s[4] A[5]=h[5]-T*s[5] Warning! This can introduce gigantic equation sets!

5 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Solving Integrals Numerically Intergral Function: F = INTEGRAL(Integrand, VarName, LowerLimit, UpperLimit, StepSize) or F = INTEGRAL(Integrand, VarName, LowerLimit, UpperLimit) {automatic step size} Differential Equations Using Integral Function: y=y0 + INT{ f(x,y) dx}

6 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Modules & Subprograms MODULE TEST(A, B : X, Y).. {Equations}. END SUBPROGRAM TEST(A, B : X, Y).. {Equations}. END Are called using a CALL statement just like procedures! (Equations are solved simultaneously) (Equations are solved internally in subprograms where after the program iterates between the subprograms and main programs until a solution is reached)

7 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Fundamental laws of thermodynamics Zeroth law: If two bodies are each in equilibrium with a third body, they are in thermal equilibrium with each other. First law:The energy is conserved ~ you can’t win! Second law:If a process occurs in a closed system, the entropy increases for irreversible processes and remains constant for reversible processes (  S  0) ~ you can’t break even! Third law:The entropy of a system goes to zero as the temperature goes to 0K, no matter the values of parameters as pressure, volume, electric fields etc. ~there is no point in trying!

8 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Interpretation of 2 nd law 2 nd lw. (altI):No series of processes is possible whose sole result is the absorption of heat from a thermal reservoir and the complete conversion of this energy to work: There are no perfect engines! 2 nd lw. (altII):No series of processes is possible whose sole result is the transfer of heat from a reservoir at a given temperature to a reservoir at a higher temperature: There are no perfect refrigerators!

9 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Properties used in thermal modelling: Thermodynamic properties Temperature T, pressure p, specific volume v and density . Calorimetric properties Specific enthalpy h, specific entropy s, specific internal energy u. Material & transport properties Specific heat capacity c p (at constant pressure) & c v (at constant volume), kinematic viscosity, dynamic viscosity . Physical & derived properties Dimension, shape, efficiency, mass flow, heat transfer coefficients etc.

10 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Conservation equations Most of the systems we consider are OPEN SYSTEMS! 1 st law: Continuity: Momentum:

11 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Steady State (Stationary conditions) If we neglect variations in kinetic energy, potential energy and momentum losses (pressure losses): Keep in mind: Energy and mass are always conserved! There are no exceptions!

12 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Molar fractions and Mass fractions Dalton’s Law: The total pressure equals the sum of the partial pressures. The partial pressures are the pressures the single components in the gas (i.e. species) would have if they were present alone in the system.

13 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Mixture Enthalpy

14 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Mixture Entropy

15 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Mixture Transport Properties Wilke’s formula:

16 Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Procedure for using Wilke’s Formula viscosity=0 lambda_gas=0 for i=1:NS interaction_sum=0 for j=1:NS int(i,j)=(1+sqrt(my(i)/my(j))*(M(j)/M(i))^(1/4))^2/(sqrt(8)*sqrt(1+(M(i)/M(j)))) interaction_sum=interaction_sum+x(j)*int(i,j) end my_gas=my_gas+x(i)*my(i)/interaction_sum lambda_gas=lambda_gas+x(i)*lambda(i)/interaction_sum end


Download ppt "Analysis, Modelling and Simulation of Energy Systems, SEE-T9 Mads Pagh Nielsen Procedures and Functions PROCEDURE TEST(A,B,C:X,Y)... X :=... Y :=... END."

Similar presentations


Ads by Google