/[ascend]/trunk/models/johnpye/fprops/asc_helmholtz.c
ViewVC logotype

Diff of /trunk/models/johnpye/fprops/asc_helmholtz.c

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

revision 2289 by hongke, Sat Aug 14 08:16:37 2010 UTC revision 2290 by jpye, Sun Aug 15 10:11:54 2010 UTC
# Line 515  int helmholtz_Tvsx_ph_calc(struct BBoxIn Line 515  int helmholtz_Tvsx_ph_calc(struct BBoxIn
515          outputs[3] = x;          outputs[3] = x;
516          return 0;          return 0;
517      }      }
518        
519      p = inputs[0];      p = inputs[0];
520      h = inputs[1];      h = inputs[1];
521    
522        double hft, pt, rhoft,rhogt;
523        res = fprops_triple_point(&pt,&rhoft,&rhogt,helmholtz_data);
524        if(res){
525            ERROR_REPORTER_HERE(ASC_PROG_ERR,"Failed to solve triple point for %s.",helmholtz_data->name);
526            return 5;
527        }
528        hft = helmholtz_h(helmholtz_data->T_t, rhoft, helmholtz_data);
529        if(h < hft){
530            ERROR_REPORTER_HERE(ASC_PROG_ERR
531                ,"Input enthalpy %f kJ/kg is below triple point liquid enthalpy %f kJ/kg"
532                ,h/1e3,hft/1e3
533            );
534            return 6;
535        }
536        
537        if(p < pt){
538            ERROR_REPORTER_HERE(ASC_PROG_ERR
539                ,"Input pressure %f bar is below triple point pressure %f bar"
540                ,p/1e5,pt/1e5
541            );
542            outputs[0] = helmholtz_data->T_t;
543            outputs[1] = 1./ rhoft;
544            outputs[2] = helmholtz_s_raw(helmholtz_data->T_t, rhoft, helmholtz_data);
545            outputs[3] = 0;
546            return 6;
547        }
548    
549      if(p < fprops_pc(helmholtz_data)){      if(p < fprops_pc(helmholtz_data)){
550          double T_sat, rho_f, rho_g;          double T_sat, rho_f, rho_g;
551          res = fprops_sat_p(p, &T_sat, &rho_f, &rho_g, helmholtz_data);          res = fprops_sat_p(p, &T_sat, &rho_f, &rho_g, helmholtz_data);
552          if(res)return 1;          if(res){
553                ERROR_REPORTER_HERE(ASC_PROG_ERR
554                    , "Failed to solve saturation state of %s for p = %f bar < pc (= %f bar)"
555                    , helmholtz_data->name, p/1e5,fprops_pc(helmholtz_data)/1e5
556                );
557                outputs[0] = helmholtz_data->T_t;
558                outputs[1] = 1./rhoft;
559                outputs[2] = helmholtz_s_raw(helmholtz_data->T_t, rhoft, helmholtz_data);
560                outputs[3] = 0;
561                return 1;
562            }
563          double hf = helmholtz_h(T_sat,rho_f, helmholtz_data);          double hf = helmholtz_h(T_sat,rho_f, helmholtz_data);
564          double hg = helmholtz_h(T_sat,rho_g, helmholtz_data);          double hg = helmholtz_h(T_sat,rho_g, helmholtz_data);
565    
# Line 541  int helmholtz_Tvsx_ph_calc(struct BBoxIn Line 578  int helmholtz_Tvsx_ph_calc(struct BBoxIn
578              outputs[1] = v;              outputs[1] = v;
579              outputs[2] = s;              outputs[2] = s;
580              outputs[3] = x;              outputs[3] = x;
581                ERROR_REPORTER_HERE(ASC_PROG_NOTE,"Saturated state, p=%f bar, h = %f kJ/kg",p/1e5,h/1e3);
582              return 0;              return 0;
583          }          }
584      }      }
# Line 556  int helmholtz_Tvsx_ph_calc(struct BBoxIn Line 594  int helmholtz_Tvsx_ph_calc(struct BBoxIn
594      outputs[1] = v;      outputs[1] = v;
595      outputs[2] = s;      outputs[2] = s;
596      outputs[3] = x;      outputs[3] = x;
597        ERROR_REPORTER_HERE(ASC_PROG_NOTE,"Non-saturated state, p = %f bar, h = %f kJ/kg",p/1e5,h/1e3);
598      return res;      return res;
599  }  }
600    

Legend:
Removed from v.2289  
changed lines
  Added in v.2290

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