/[ascend]/branches/jacob/models/johnpye/fprops/mix_test/jacob_mix_test6--reverse-high-p.a4c
ViewVC logotype

Contents of /branches/jacob/models/johnpye/fprops/mix_test/jacob_mix_test6--reverse-high-p.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3085 - (show annotations) (download) (as text)
Fri Aug 21 19:00:30 2015 UTC (3 years, 8 months ago) by jacob
File MIME type: text/x-ascend
File size: 4377 byte(s)
remove some obsolete functions, and move test functions
1 (* ASCEND multi-component ideal-solution routine
2
3 To perform the simulation, load the file into ASCEND and run 'setup'.
4
5 This file finds temperature from enthalpy, the reverse of the usual
6 order. Two methods are used -- solving for the temperature in
7 Ascend, and solving for it with a special-purpose .c function.
8
9 The main difference between 'jacob_mix_test6--reverse-solve.a4c' and
10 this file is that the pressure and enthalpy are set significantly
11 higher in this file; the intention here is to test the modeling
12 library at high temperatures and pressures.
13
14 The (provisional) conclusion from this file's results is that the
15 different methods of finding temperature from enthalpy do not always
16 give the same results (possibly due to the effect of changing phase
17 equilibrium), and the external relation may not always successfully
18 converge.
19 *)
20
21 REQUIRE "atoms.a4l";
22 REQUIRE "johnpye/thermo_types.a4c";
23 IMPORT "johnpye/fprops/mixture";
24 REQUIRE "johnpye/fprops/mixtures.a4l";
25
26 (* ---------------------------------------------------------------------
27 The mixture_test model *)
28 MODEL mixture_test;
29 (* -----------------------------------------------------------------
30 Declare variables to hold various mixture properties *)
31 T, (* temperature calculated from enthalpy in ASCEND *)
32 T_ext IS_A temperature; (* temperature calculated with external relation *)
33 p IS_A pressure; (* mixture pressure *)
34
35 h, (* fixed enthalpy used to find temperatures *)
36 h_back, (* enthalpy calculated from temperature *)
37 h_back_ext IS_A specific_enthalpy; (* enthalpy calculated from temperature *)
38
39 rho, (* mixture density *)
40 rho_ph1, rho_ph2 IS_A mass_density; (* density of phases 1 and 2 *)
41
42 (* -----------------------------------------------------------------
43 Declare variables to hold phase-accounting data *)
44 phases, (* number of phases *)
45 ph1, ph2 IS_A phase_count; (* phases 1 and 2 *)
46 ph_frac[1..3] IS_A mass_fraction; (* mass fraction of each phase *)
47
48 (* -----------------------------------------------------------------
49 Declare and specify a mixture with its composition *)
50 mixt IS_A mixture_spec;
51 mixt.npure :== 4;
52 mixt.components[1] :== 'ammonia';
53 mixt.components[2] :== 'cyclohexane';
54 mixt.components[3] :== 'water';
55 mixt.components[4] :== 'toluene';
56 mixt.eos :== 'pengrob';
57 mixt.xs[1] :== 0.30;
58 mixt.xs[2] :== 0.25;
59 mixt.xs[3] :== 0.35;
60 mixt.xs[4] :== 0.10;
61
62 (* -----------------------------------------------------------------
63 Find temperature from enthalpy *)
64 mix_temperature : mixture_h(
65 T, p : INPUT;
66 h : OUTPUT;
67 mixt : DATA
68 );
69 mix_temperature_external : mixture_state_T_ph(
70 p, h : INPUT;
71 T_ext : OUTPUT;
72 mixt : DATA
73 );
74
75 (* -----------------------------------------------------------------
76 Find enthalpies again from temperatures *)
77 mix_enthalpy_back : mixture_h(
78 T, p : INPUT;
79 h_back : OUTPUT;
80 mixt : DATA
81 );
82 mix_enthalpy_back_ext : mixture_h(
83 T_ext, p : INPUT;
84 h_back_ext : OUTPUT;
85 mixt : DATA
86 );
87
88 (* -----------------------------------------------------------------
89 Find number of phases, mass fractions of phases *)
90 mix_phases : mixture_count_phases(
91 T, p : INPUT;
92 phases, ph_frac[1], ph_frac[2], ph_frac[3] : OUTPUT;
93 mixt : DATA
94 );
95
96 (* -----------------------------------------------------------------
97 Find phase and component densities *)
98 mix_density : mixture_rho(
99 T, p : INPUT;
100 rho : OUTPUT;
101 mixt : DATA
102 );
103 mix_phase1_density : mixture_phase_rho(
104 T, p, ph1 : INPUT;
105 rho_ph1 : OUTPUT;
106 mixt : DATA
107 );
108 mix_phase2_density : mixture_phase_rho(
109 T, p, ph2 : INPUT;
110 rho_ph2 : OUTPUT;
111 mixt : DATA
112 );
113
114 METHODS
115 (* Fix the variables that are to be fixed *)
116 METHOD specify;
117 FIX h;
118 FIX p;
119 FIX ph1;
120 FIX ph2;
121 END specify;
122 (* Set values of the fixed variables *)
123 METHOD values;
124 h := 1500000 {J/kg};
125 p := 10 {bar};
126 ph1 := 1;
127 ph2 := 2;
128 END values;
129 (* Set solver and other options *)
130 METHOD options;
131 SOLVER QRSlv;
132 OPTION convopt 'RELNOM_SCALE';
133 END options;
134 (* Quick alias for all preceeding methods; readies the model for solving *)
135 METHOD setup;
136 RUN specify;
137 RUN values;
138 RUN options;
139 END setup;
140 END mixture_test;

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22