/[ascend]/branches/jacob/models/johnpye/fprops/mixtures/init_mixfuncs.h
ViewVC logotype

Contents of /branches/jacob/models/johnpye/fprops/mixtures/init_mixfuncs.h

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-chdr
File size: 3694 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 5-, 2015
23
24 Function headers for initial model of ideal-solution mixing. Removed these
25 from the test files init_mix1, init_mix2, etc. to de-clutter them.
26 */
27
28 #ifndef INIT_MIXTURE_HEADER
29 #define INIT_MIXTURE_HEADER
30
31 #include "mixture_struct.h"
32 #include "../helmholtz.h"
33 #include "../fluids.h"
34 #include "../fprops.h"
35 #include "../refstate.h"
36 #include "../sat.h"
37
38 #include <stdio.h>
39 #include <math.h>
40
41 #define MIX_ERROR " ERROR: "
42 #define MIX_XSUM_ERROR MIX_ERROR "the sum over all mass fractions, which should be exactly 1.00, is %.10f\n"
43
44 #define PREPARE_TABLE(ROWS,COLS,T_HEAD,T_SIDE,T_VALS,T_FORM,T_CONT) \
45 for(i2=0;i2<COLS-1;i2++){ \
46 T_CONT[0][i2+1] = T_HEAD[i2]; \
47 } \
48 for(i1=0;i1<ROWS;i1++){ \
49 T_CONT[i1][0] = T_SIDE[i1]; \
50 } \
51 for(i1=0;i1<ROWS-1;i1++){ \
52 for(i2=0;i2<COLS-1;i2++){ \
53 T_CONT[i1+1][i2+1] = (char *)malloc(20); \
54 snprintf(T_CONT[i1+1][i2+1], 100, T_FORM[i1], T_VALS[i1][i2]); \
55 } \
56 }
57
58 #define PRINT_STR_TABLE(ROWS,COLS,CWIDTH,CELLS) \
59 for(i1=0;i1<ROWS;i1++){ \
60 for(i2=0;i2<COLS;i2++){ \
61 if(strlen(CELLS[i1][i2])>=CWIDTH[i2]){ \
62 CWIDTH[i2] = strlen(CELLS[i1][i2]); \
63 } \
64 } \
65 } \
66 printf("\n"); \
67 for(i1=0;i1<ROWS;i1++){ \
68 for(i2=0;i2<COLS;i2++){ \
69 printf(" %s ", CELLS[i1][i2]); \
70 for(i3=0;i3<(CWIDTH[i2] - strlen(CELLS[i1][i2]));i3++){ \
71 printf("%c", ' '); \
72 } \
73 } \
74 printf("\n"); \
75 }
76
77 /* Function prototypes */
78 void mixture_x_props(unsigned nPure, double *Xs, double *props);
79 double mixture_x_fill_in(unsigned nPure, double *Xs);
80 void ig_rhos(MixtureState *M, double P, char **Names);
81 void initial_rhos(MixtureState *M, double P, char **names, FpropsError *err);
82 void pressure_rhos(MixtureState *M, double P, double tol, /* char **Names, */ FpropsError *err);
83 void densities_to_mixture(MixtureState *M, double tol, char **Names, FpropsError *err);
84
85 double mixture_rho(MixtureState *M);
86 double mixture_u(MixtureState *M, FpropsError *err);
87 double mixture_h(MixtureState *M, FpropsError *err);
88 double mixture_cp(MixtureState *M, FpropsError *err);
89 double mixture_cv(MixtureState *M, FpropsError *err);
90 double mixture_x_ln_x(unsigned nPure, double *Xs, PureFluid **PFs);
91 double mixture_M_avg(unsigned nPure, double *Xs, PureFluid **PFs);
92 double mixture_s(MixtureState *M, FpropsError *err);
93 double mixture_g(MixtureState *M, FpropsError *err);
94 double mixture_a(MixtureState *M, FpropsError *err);
95
96 void print_mixture_properties(char *how_calc, double rho, double u, double h, double cp, double cv, double s, double g, double a);
97 void print_substances_properties(unsigned subst, char **headers, double *Xs, double *rhos, double *ps, double *us, double *hs, double *cps, double *cvs, double *ss, double *gs, double *as);
98 void print_cases_properties(unsigned cases, char **headers, double *rhos, double *ps, double *us, double *hs, double *cps, double *cvs, double *ss, double *gs, double *as);
99
100 #endif
101

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