// adiabatictemp.cpp // // last-edit-by: J.A. de Jong // // Description: // ////////////////////////////////////////////////////////////////////// #define TRACERPLUS 10 #include "adiabatictemp.h" #include "perfectgas.h" #include "tasmet_variable.h" #include "tasmet_tracer.h" #include "tasmet_exception.h" #include "brent.h" struct AdiabaticTemp : public NoGradientNonlinearSystem { d p,p0,Rs,T0; d T; const PerfectGas& gas; // Careful here, reference! const vd& cpc; // Here too! d gamma0; // Used for initial guess AdiabaticTemp(const PerfectGas& gas,d p): gas(gas), cpc(gas.cpc()) { p0 = gas.p0(); T0 = gas.T0(); Rs = gas.Rs(); gamma0 = gas.gamma(T0,p0); #ifdef TASMET_DEBUG if(cpc.size() < 1) throw TaSMETError("Invalid array of heat capacity coefficients"); #endif setP(p); } d getSolution() const { return T; } void updateSolution(const d& T) { this->T=T;} AdiabaticTemp* copy() const { return new AdiabaticTemp(gas,p);} // Set a pressure to solve the temperature for void setP(d p) { this->p = p; // Good initial guess T = T0*pow(p/p0,(gamma0-1)/gamma0); } // Final function to solve for d residual() const { // Do the integration for the temperature d lhs = (cpc(0)/Rs)*log(T/T0); for(us i=1;i cb = solver_callback; for(us i=0;i