/[ascend]/branches/jacob/models/johnpye/fprops/mix_test/jacob_mix_test1--whole-mix1.a4c
ViewVC logotype

Contents of /branches/jacob/models/johnpye/fprops/mix_test/jacob_mix_test1--whole-mix1.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, 9 months ago) by jacob
File MIME type: text/x-ascend
File size: 3823 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 performs a general test of (mostly) whole-mixture
6 properties as calculated with the ideal-solution functions.
7 *)
8
9 REQUIRE "atoms.a4l";
10 REQUIRE "johnpye/thermo_types.a4c";
11 IMPORT "johnpye/fprops/mixture";
12 REQUIRE "johnpye/fprops/mixtures.a4l";
13
14 (* ---------------------------------------------------------------------
15 The mixture_test model *)
16 MODEL mixture_test;
17 (* Declare variables to hold various mixture properties *)
18 T IS_A temperature; (* mixture temperature *)
19 p IS_A pressure; (* mixture pressure; with 'T' this sets the state *)
20 rho, (* mixture density *)
21 phase_rho[1..3] IS_A mass_density; (* mass density of each phase *)
22 u, (* mixture internal energy *)
23 u_ph1 IS_A specific_energy; (* phase 1 internal energy *)
24 h IS_A specific_enthalpy; (* mixture enthalpy *)
25 s IS_A specific_entropy; (* mixture entropy *)
26 g IS_A specific_secondary_energy; (* mixture Gibbs energy *)
27 a IS_A specific_secondary_energy; (* mixture Helmholtz energy *)
28
29 (* Declare variables to hold phase-accounting data *)
30 nphase, (* number of phases *)
31 ph, (* first phase *)
32 num_comps IS_A phase_count; (* mass fraction of each phase *)
33 phase_frac[1..3] IS_A mass_fraction; (* mass fraction of each phase *)
34
35 (* Declare and specify a mixture with its composition *)
36 mixt IS_A mixture_spec;
37 mixt.npure :== 3;
38 mixt.components[1] :== 'ammonia';
39 mixt.components[2] :== 'carbondioxide';
40 mixt.components[3] :== 'cyclohexane';
41 mixt.eos :== 'pengrob';
42 mixt.xs[1] :== 0.4;
43 mixt.xs[2] :== 0.35;
44 mixt.xs[3] :== 0.25;
45
46 (* -----------------------------------------------------------------
47 Find the number of phases and phase mass fractions in the mixture *)
48 mix_phase_data : mixture_flash_phases(
49 T, p : INPUT;
50 nphase, phase_frac[1], phase_frac[2], phase_frac[3] : OUTPUT;
51 mixt : DATA
52 );
53
54 (* -----------------------------------------------------------------
55 Find the number of components in the first phase *)
56 mix_phase_components : mixture_phase_components(
57 T, p, ph : INPUT;
58 num_comps : OUTPUT;
59 mixt : DATA
60 );
61
62 (* -----------------------------------------------------------------
63 Find the whole-mixture mass density *)
64 mix_density : mixture_rho(
65 T, p : INPUT;
66 rho : OUTPUT;
67 mixt : DATA
68 );
69
70 (* -----------------------------------------------------------------
71 Find the first-law properties: overall and by-phase internal
72 energy, overall enthalpy *)
73 mix_u : mixture_u(
74 T, p : INPUT;
75 u : OUTPUT;
76 mixt : DATA
77 );
78 mix_phase_u : mixture_phase_u(
79 T, p, ph : INPUT;
80 u_ph1 : OUTPUT;
81 mixt : DATA
82 );
83 mix_h : mixture_h(
84 T, p : INPUT;
85 h : OUTPUT;
86 mixt : DATA
87 );
88
89 (* -----------------------------------------------------------------
90 Find second-law properties: overall entropy, Gibbs energy, and
91 Helmholtz energy *)
92 mix_s : mixture_s(
93 T, p : INPUT;
94 s : OUTPUT;
95 mixt : DATA
96 );
97 mix_g : mixture_g(
98 T, p : INPUT;
99 g : OUTPUT;
100 mixt : DATA
101 );
102 mix_a : mixture_a(
103 T, p : INPUT;
104 a : OUTPUT;
105 mixt : DATA
106 );
107
108 METHODS
109 (* Fix the variables that are to be fixed *)
110 METHOD specify;
111 FIX T;
112 FIX p;
113 FIX ph;
114 END specify;
115 (* Set values of the fixed variables *)
116 METHOD values;
117 T := 300 {K} + 273.15 {K};
118 p := 2 {bar};
119 ph := 1;
120 END values;
121 (* Set solver and other options *)
122 METHOD options;
123 SOLVER QRSlv;
124 OPTION convopt 'RELNOM_SCALE';
125 END options;
126 (* Quick alias for all preceeding methods; readies the model for solving *)
127 METHOD setup;
128 RUN specify;
129 RUN values;
130 RUN options;
131 END setup;
132 END mixture_test;

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