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

Contents of /branches/jacob/models/johnpye/fprops/jacob_mix_test6--reverse-solve.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3079 - (show annotations) (download) (as text)
Thu Aug 20 02:17:28 2015 UTC (3 years, 9 months ago) by jacob
File MIME type: text/x-ascend
File size: 4121 byte(s)
Review format of comments used to create doxygen documentaion.  Begin ammending erroneous formatting in previously written doxygen comments in the mixture code.

Added further commentary and documentation to .a4c test files

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 (provisional) conclusion from this file's results is that the
10 different methods of finding temperature from enthalpy do not always
11 give the same results (possibly due to the effect of changing phase
12 equilibrium), and the external relation may not always successfully
13 converge.
14 *)
15
16 REQUIRE "atoms.a4l";
17 REQUIRE "johnpye/thermo_types.a4c";
18 IMPORT "johnpye/fprops/mixture";
19 REQUIRE "johnpye/fprops/mixtures.a4l";
20
21 (* ---------------------------------------------------------------------
22 The mixture_test model *)
23 MODEL mixture_test;
24 (* -----------------------------------------------------------------
25 Declare variables to hold various mixture properties *)
26 T, (* temperature calculated from enthalpy in ASCEND *)
27 T_ext IS_A temperature; (* temperature calculated with external relation *)
28 p IS_A pressure; (* mixture pressure *)
29
30 h, (* fixed enthalpy used to find temperatures *)
31 h_back, (* enthalpy calculated from temperature *)
32 h_back_ext IS_A specific_enthalpy; (* enthalpy calculated from temperature *)
33
34 rho, (* mixture density *)
35 rho_ph1, rho_ph2 IS_A mass_density; (* density of phases 1 and 2 *)
36
37 (* -----------------------------------------------------------------
38 Declare variables to hold phase-accounting data *)
39 phases, (* number of phases *)
40 ph1, ph2 IS_A phase_count; (* phases 1 and 2 *)
41 ph_frac[1..3] IS_A mass_fraction; (* mass fraction of each phase *)
42
43 (* -----------------------------------------------------------------
44 Declare and specify a mixture with its composition *)
45 mixt IS_A mixture_spec;
46 mixt.npure :== 4;
47 mixt.components[1] :== 'ammonia';
48 mixt.components[2] :== 'carbonmonoxide';
49 mixt.components[3] :== 'cyclohexane';
50 mixt.components[4] :== 'benzene';
51 mixt.eos :== 'pengrob';
52 mixt.xs[1] :== 0.3;
53 mixt.xs[2] :== 0.35;
54 mixt.xs[3] :== 0.20;
55 mixt.xs[4] :== 0.15;
56
57 (* -----------------------------------------------------------------
58 Find temperature from enthalpy *)
59 mix_temperature : mixture_h(
60 T, p : INPUT;
61 h : OUTPUT;
62 mixt : DATA
63 );
64 mix_temperature_external : mixture_state_T_ph(
65 p, h : INPUT;
66 T_ext : OUTPUT;
67 mixt : DATA
68 );
69
70 (* -----------------------------------------------------------------
71 Find enthalpies again from temperatures *)
72 mix_enthalpy_back : mixture_h(
73 T, p : INPUT;
74 h_back : OUTPUT;
75 mixt : DATA
76 );
77 mix_enthalpy_back_ext : mixture_h(
78 T_ext, p : INPUT;
79 h_back_ext : OUTPUT;
80 mixt : DATA
81 );
82
83 (* -----------------------------------------------------------------
84 Find number of phases, mass fractions of phases *)
85 mix_phases : mixture_count_phases(
86 T, p : INPUT;
87 phases, ph_frac[1], ph_frac[2], ph_frac[3] : OUTPUT;
88 mixt : DATA
89 );
90
91 (* -----------------------------------------------------------------
92 Find phase and component densities *)
93 mix_density : mixture_rho(
94 T, p : INPUT;
95 rho : OUTPUT;
96 mixt : DATA
97 );
98 mix_phase1_density : mixture_phase_rho(
99 T, p, ph1 : INPUT;
100 rho_ph1 : OUTPUT;
101 mixt : DATA
102 );
103 mix_phase2_density : mixture_phase_rho(
104 T, p, ph2 : INPUT;
105 rho_ph2 : OUTPUT;
106 mixt : DATA
107 );
108
109 METHODS
110 (* Fix the variables that are to be fixed *)
111 METHOD specify;
112 FIX h;
113 FIX p;
114 FIX ph1;
115 FIX ph2;
116 END specify;
117 (* Set values of the fixed variables *)
118 METHOD values;
119 h := 700000 {J/kg};
120 p := 2 {bar};
121 ph1 := 1;
122 ph2 := 2;
123 END values;
124 (* Set solver and other options *)
125 METHOD options;
126 SOLVER QRSlv;
127 OPTION convopt 'RELNOM_SCALE';
128 END options;
129 (* Quick alias for all preceeding methods; readies the model for solving *)
130 METHOD setup;
131 RUN specify;
132 RUN values;
133 RUN options;
134 END setup;
135 END mixture_test;

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