/[ascend]/branches/jacob/models/johnpye/fprops/mixtures/mixture_prepare.c
ViewVC logotype

Contents of /branches/jacob/models/johnpye/fprops/mixtures/mixture_prepare.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2988 - (show annotations) (download) (as text)
Tue Jun 30 04:00:24 2015 UTC (3 years, 4 months ago) by jacob
File MIME type: text/x-csrc
File size: 2346 byte(s)
expanded new library file to export mixture functions, and test .a4c file to check that the functions are exported correctly, and receive correct data.

minor changes to <ascend/compiler/instance_enum.h>, adding a few macro definitions of ASCEND data types for library file to be able to mention by name.

1 /* ASCEND modelling environment
2 Copyright (C) Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation --
17
18 Free Software Foundation, Inc.
19 59 Temple Place - Suite 330
20 Boston, MA 02111-1307, USA.
21 *//*
22 by Jacob Shealy, June 25-, 2015
23
24 Functions to prepare structs that represent mixtures when modeling mixtures
25 */
26
27 #include "mixture_generics.h"
28 #include "mixture_prepare.h"
29 #include "mixture_struct.h"
30 #include "../helmholtz.h"
31 #include "../fluids.h"
32 #include "../fprops.h"
33 #include "../refstate.h"
34 #include "../sat.h"
35
36 /**
37 Specify a mixture, without specifying state (temperature, pressure, or
38 densities) of the mixture.
39
40 @param npure number of pure components in the mixture
41 @param Xs array of mass fractions
42 @param fluids names of the pure components
43 @param type name of the correlation type (equation of state) used to model
44 the components
45 @param source name of sources for component data
46
47 @return a mixture specification (struct MixtureSpec)
48 */
49 MixtureSpec *mixture_specify(unsigned npure, double *Xs, void **fluids, char *type, char **source, MixtureError *merr){
50 unsigned i;
51 double X_sum=0.0;
52 PureFluid *PF[npure];
53
54 for(i=0;i<npure;i++){
55 X_sum += Xs[i];
56 }
57 if(fabs(X_sum - 1.0) > MIX_XTOL){
58 *merr = MIXTURE_XSUM_ERROR;
59 }
60
61 if(strcmp(type, "ideal")){ /* model fluids with ideal-gas equation of state */
62 EosData **ig_fluids = (EosData **)fluids;
63 ReferenceState ref = {FPROPS_REF_REF0};
64
65 for(i=0;i<npure;i++){
66 PF[i] = ideal_prepare(ig_fluids[i], &ref);
67 }
68 }else{ /* use some other equation of state */
69 char **fluid_names = (char **)fluids;
70
71 for(i=0;i<npure;i++){
72 PF[i] = fprops_fluid(fluid_names[i],type,source[i]);
73 }
74 }
75
76 MixtureSpec MS = {
77 .pures = npure,
78 .Xs = Xs,
79 .PF = PF,
80 };
81
82 return &MS;
83 }
84

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