/[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 3061 - (show annotations) (download) (as text)
Thu Aug 13 15:01:49 2015 UTC (3 years, 11 months ago) by jacob
File MIME type: text/x-csrc
File size: 2410 byte(s)
Renamed .a4c test files beginning with 'jacob_mix_', and gave more informative names

Extended dew and bubble-point functions (finding pressure or temperature) which check that mixture is not in the critical region.  Added dew and bubble-point functions to API, with proper checks on region.

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 #include <stdio.h>
36
37 /*
38 Specify the composition of a mixture as a complete MixtureSpec, but do not
39 specify the mixture state (temperature, pressure, or densities).
40
41 @param npure number of pure components in the mixture
42 @param Xs array of mass fractions
43 @param fluids names of the pure components
44 @param type name of the correlation type (equation of state) used to model
45 the components
46 @param source name of sources for component data
47
48 @return a mixture specification (struct MixtureSpec)
49 */
50 void mixture_specify(MixtureSpec *MS, const unsigned npure, const double *Xs
51 , const void **fluids, const char *type, const char **source, MixtureError *merr){
52 MSG("Entered the function...");
53 unsigned i;
54 double X_sum=0.0;
55
56 MS->pures = npure;
57 MS->Xs = ASC_NEW_ARRAY(double,npure);
58 MS->PF = ASC_NEW_ARRAY(PureFluid *,npure);
59
60 for(i=0;i<npure;i++){
61 X_sum += Xs[i];
62 MS->Xs[i] = Xs[i];
63 }
64 if(fabs(X_sum - 1.0) > MIX_XTOL){
65 MSG_MARK(" 3.1");
66 *merr = MIXTURE_XSUM_ERROR;
67 }
68 char **fluid_names = (char **)fluids;
69
70 for(i=0;i<npure;i++){
71 MS->PF[i] = fprops_fluid(fluid_names[i],type,source[i]);
72 MSG("Prepared fluid %s", fluid_names[i]);
73 }
74
75 for(i=0;i<npure;i++){
76 MSG("Fluid number %u at %p is %s, modeled with %u"
77 , i, MS->PF[i], MS->PF[i]->name, MS->PF[i]->type);
78 }
79 }
80

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