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

Diff of /branches/jacob/models/johnpye/fprops/mixtures/asc_idealsolution.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2987 by jacob, Fri Jun 26 04:35:50 2015 UTC revision 2988 by jacob, Tue Jun 30 04:00:24 2015 UTC
# Line 26  Line 26 
26    
27  #include <ascend/utilities/error.h>  #include <ascend/utilities/error.h>
28  #include <ascend/general/platform.h>  #include <ascend/general/platform.h>
 #include <ascend/general/extfunc.h>  
29  #include <ascend/general/list.h>  #include <ascend/general/list.h>
30    #include <ascend/compiler/extfunc.h>
31  #include <ascend/compiler/parentchild.h>  #include <ascend/compiler/parentchild.h>
32  /*  /*
33      #include <ascend/compiler/child.h>      #include <ascend/compiler/child.h>
# Line 63  ExtBBoxFunc mixture_rho_calc; Line 63  ExtBBoxFunc mixture_rho_calc;
63  static symchar *mix_symbols[5];  static symchar *mix_symbols[5];
64  enum Symbol_Enum {NPURE_SYM, COMP_SYM, X_SYM, TYPE_SYM, SOURCE_SYM};  enum Symbol_Enum {NPURE_SYM, COMP_SYM, X_SYM, TYPE_SYM, SOURCE_SYM};
65    
66  static const char *mixture_p_help = "Calculate pressure for the mixture, using ideal solution assumption, and report if pressure is inconsistent among the densities"  static const char *mixture_p_help = "Calculate pressure for the mixture, using ideal solution assumption, and report if pressure is inconsistent among the densities";
67  static const char *mixture_rho_help = "Calculate overall density of the solution, using ideal-solution assumption"  static const char *mixture_rho_help = "Calculate overall density of the solution, using ideal-solution assumption";
68    
69  /*  /*
70      Register all functions that will be exported      Register all functions that will be exported
# Line 75  extern ASC_EXPORT int mixture_register() Line 75  extern ASC_EXPORT int mixture_register()
75      ERROR_REPORTER_HERE(ASC_USER_WARNING,      ERROR_REPORTER_HERE(ASC_USER_WARNING,
76              "FPROPS in general, and IN PARTICULAR this mixture module, "              "FPROPS in general, and IN PARTICULAR this mixture module, "
77              "are still EXPERIMENTAL.  Use with caution.");              "are still EXPERIMENTAL.  Use with caution.");
78    
79    #define QQZX 3
80        
81  #define CALCFN(NAME,INPUTS,OUTPUTS) \  #define CALCFN(NAME,INPUTS,OUTPUTS) \
82      result += CreateUserFunctionBlackBox(#Name \      result += CreateUserFunctionBlackBox( #NAME \
83              , asc_mixture_prepare \              , asc_mixture_prepare \
84              , NAME##_calc              /* value */ \              , NAME##_calc              /* value */ \
85              , (ExtBBoxFunc *)NULL      /* derivatives -- none */ \              , (ExtBBoxFunc *)NULL      /* derivatives -- none */ \
# Line 99  extern ASC_EXPORT int mixture_register() Line 102  extern ASC_EXPORT int mixture_register()
102  /*  /*
103      Function which prepares persistent data      Function which prepares persistent data
104   */   */
105  int asc_mixture_prepare(struct BBoxInterp *bbox, struct Instance *data, struct g_list_t *arglist){  int asc_mixture_prepare(struct BBoxInterp *bbox, struct Instance *data, struct gl_list_t *arglist){
106    
107  #define CHECK_TYPE(VAR,TYPE,NAME,TYPENAME) \  #define CHECK_TYPE(VAR,TYPE,NAME,TYPENAME) \
108      if(InstanceKind(VAR)!=TYPE){ \      if(InstanceKind(VAR)!=TYPE){ \
109          ERROR_REPORTER_HERE(ASC_USER_ERROR \          ERROR_REPORTER_HERE(ASC_USER_ERROR \
110              , "DATA member '%s' has type-value %x, but must have %s (value %x)" \              , "DATA member '%s' has type-value %#o, but must have %s (value %#o)" \
111              , NAME, InstanceKind(VAR), TYPENAME, TYPE); \              , NAME, InstanceKind(VAR), TYPENAME, TYPE); \
112          return 1; \          return 1; \
113      }      }
# Line 117  int asc_mixture_prepare(struct BBoxInter Line 120  int asc_mixture_prepare(struct BBoxInter
120      CHECK_TYPE(VAR,TYPE,NAME,TYPENAME)      CHECK_TYPE(VAR,TYPE,NAME,TYPENAME)
121    
122      struct Instance *npureinst, *compinst, *xinst, *typeinst, *srcinst;      struct Instance *npureinst, *compinst, *xinst, *typeinst, *srcinst;
123      const unsigned npure;      unsigned npure;
124    
125      mix_symbols[0] = AddSymbol("npure");      mix_symbols[0] = AddSymbol("npure");
126      mix_symbols[1] = AddSymbol("components");      mix_symbols[1] = AddSymbol("components");
# Line 140  int asc_mixture_prepare(struct BBoxInter Line 143  int asc_mixture_prepare(struct BBoxInter
143      } */      } */
144      npure = (int *)IC_INST(npureinst)->value;      npure = (int *)IC_INST(npureinst)->value;
145    
146      const gl_list_t *comps_gl;      const struct gl_list_t *comps_gl;
147      const char *comps[npure], *type=NULL, *src=NULL;      const char *comps[npure], *type=NULL, *source=NULL;
148      const double *xs[npure];      const double *xs[npure];
149    
150      /* component names -- required */      /* component names -- required */
151      compinst = ChildByChar(data, mix_symbols[COMP_SYM]);      compinst = ChildByChar(data, mix_symbols[COMP_SYM]);
     /* if(!compinst){  
         ERROR_REPORTER_HERE(ASC_USER_ERROR  
             , "Couldn't locate 'component' in DATA, please check usage");  
     }  
     if(InstanceKind(compinst)!=ARRAY_ENUM_INST){  
         ERROR_REPORTER_HERE(ASC_USER_ERROR  
             , "DATA member 'component' was of type number %x, "  
             "but must be an array of symbol_constant(s) %x",  
             InstanceKind(compinst), )  
     } */  
152      CHECK_EXIST_TYPE(compinst, ARRAY_ENUM_INST, "components",      CHECK_EXIST_TYPE(compinst, ARRAY_ENUM_INST, "components",
153              "array of symbol_constant(s)");              "array of symbol_constant(s)");
154      comps_gl = ARY_INST(compinst)->children;      comps_gl = ARY_INST(compinst)->children;

Legend:
Removed from v.2987  
changed lines
  Added in v.2988

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