doublereal LatticePhase:: enthalpy_mole() const { doublereal p0 = m_spthermo->refPressure(); return GasConstant * temperature() * mean_X(&enthalpy_RT_ref()[0]) + (pressure() - p0)/molarDensity(); }
void StoichSubstanceSSTP::getEnthalpy_RT(doublereal* hrt) const { getEnthalpy_RT_ref(hrt); doublereal RT = GasConstant * temperature(); doublereal presCorrect = (m_press - m_p0) / molarDensity(); hrt[0] += presCorrect / RT; }
void IdealGasPhase::getStandardVolumes(doublereal* vol) const { double tmp = 1.0 / molarDensity(); for (size_t k = 0; k < m_kk; k++) { vol[k] = tmp; } }
void IdealGasPhase::getPartialMolarVolumes(doublereal* vbar) const { double vol = 1.0 / molarDensity(); for (size_t k = 0; k < m_kk; k++) { vbar[k] = vol; } }
void LatticePhase::_updateThermo() const { doublereal tnow = temperature(); if (fabs(molarDensity() - m_molar_density)/m_molar_density > 0.0001) { throw CanteraError("_updateThermo","molar density changed from " +fp2str(m_molar_density)+" to "+fp2str(molarDensity())); } if (m_tlast != tnow) { m_spthermo->update(tnow, &m_cp0_R[0], &m_h0_RT[0], &m_s0_R[0]); m_tlast = tnow; for (size_t k = 0; k < m_kk; k++) { m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k]; } m_tlast = tnow; } }
void LatticePhase::getEnthalpy_RT(doublereal* hrt) const { const array_fp& _h = enthalpy_RT_ref(); std::copy(_h.begin(), _h.end(), hrt); doublereal tmp = (pressure() - m_p0) / (molarDensity() * GasConstant * temperature()); for (size_t k = 0; k < m_kk; k++) { hrt[k] += tmp; } }
doublereal LatticeSolidPhase::intEnergy_mole() const { _updateThermo(); doublereal ndens, sum = 0.0; int n; for (n = 0; n < m_nlattice; n++) { ndens = m_lattice[n]->molarDensity(); sum += ndens * m_lattice[n]->intEnergy_mole(); } return sum/molarDensity(); }
void ConstDensityThermo::getChemPotentials(doublereal* mu) const { doublereal vdp = (pressure() - m_spthermo->refPressure())/ molarDensity(); doublereal xx; doublereal rt = temperature() * GasConstant; const array_fp& g_RT = gibbs_RT(); for (int k = 0; k < m_kk; k++) { xx = fmaxx(SmallNumber, moleFraction(k)); mu[k] = rt*(g_RT[k] + log(xx)) + vdp; } }
void LatticeSolidPhase::getStandardChemPotentials(doublereal* mu0) const { _updateThermo(); int n; int strt = 0; double dratio; for (n = 0; n < m_nlattice; n++) { dratio = m_lattice[n]->molarDensity()/molarDensity(); m_lattice[n]->getStandardChemPotentials(mu0+strt); scale(mu0 + strt, mu0 + strt + m_lattice[n]->nSpecies(), mu0 + strt, dratio); strt += m_lattice[n]->nSpecies(); } }
doublereal ConstDensityThermo::intEnergy_mole() const { doublereal p0 = m_spthermo->refPressure(); return GasConstant * temperature() * mean_X(&enthalpy_RT()[0]) - p0/molarDensity(); }
void StoichSubstance::getIntEnergy_RT_ref(doublereal* urt) const { _updateThermo(); urt[0] = m_h0_RT - m_p0 / molarDensity() / RT(); }
doublereal StoichSubstance::enthalpy_mole() const { return intEnergy_mole() + m_press / molarDensity(); }
int main(int argc, char **args) { double maxdepth; double maxtime; double vertlayer; double timestep; double surfacerate; double surfacepressure; double c13diffusivityfactor; double c13prodfactor; double tortuosity; double qfactor; double dao; double d; double A0; double TAverage; Delta13CSimulation sim; //Read the config-file readConfig(&maxdepth, &maxtime, &vertlayer, ×tep, &surfacerate, &surfacepressure, &c13diffusivityfactor, &tortuosity, &qfactor, &dao, &d, &A0, &TAverage, &c13prodfactor); //Initialize the simulation printf("Initialize the parameters, allocate memory...\n"); initialize(&sim, maxdepth, maxtime, vertlayer, timestep, surfacerate, surfacepressure, 1, tortuosity, qfactor, dao, 1, "12C"); printf("Done!\n"); //Calculate the temperature matrix printf("Calculating the temperature matrix ... \n"); temperature(&sim, d, A0, TAverage); printf("Done!\n"); //Calculate the diffusivity matrix printf("Calculating the diffusivities ... \n"); diffusivity(&sim); printf("Done!\n"); //Calculate the CO2 profile printf("Calculating the CO2 profiles ... \n"); co2Production(&sim, VARIABLEPROD); printf("Done!\n"); //Calculate vertical fluxes, the molar density and the delta 13 C for(int timeStep = 0; timeStep < sim.timeIndexMax; timeStep++) { for(int depthStep = 0; depthStep < sim.depthIndexMax; depthStep++) { verticalFlux(&sim, depthStep, timeStep); molarDensity(&sim, depthStep, timeStep, AIRFILLEDPOROSITY); } delta13cSurfaceFlux(&sim, timeStep); } //Write the results to the HDD //printf("Writing results to the HDD ... \n"); //writeToFile(&sim); //writeToFile(&sim2); //printf("Done!\n"); //Deallocate the memory printf("Deallocating arrays ... \n"); cleaning(&sim, -1); printf("Done!\n"); return 0; }
/* * Molar internal energy or the reference state at the current * temperature, T (J/kmol). * For an incompressible, * stoichiometric substance, the molar internal energy is * independent of pressure. Since the thermodynamic properties * are specified by giving the standard-state enthalpy, the * term \f$ P_0 \hat v\f$ is subtracted from the specified molar * enthalpy to compute the molar internal energy. * * Note, this is equal to the standard state internal energy * evaluated at the reference pressure. */ void StoichSubstanceSSTP::getIntEnergy_RT_ref(doublereal* urt) const { _updateThermo(); doublereal RT = GasConstant * temperature(); doublereal PV = m_p0 / molarDensity(); urt[0] = m_h0_RT[0] - PV / RT; }
void MineralEQ3::getEnthalpy_RT(doublereal* hrt) const { getEnthalpy_RT_ref(hrt); doublereal presCorrect = (m_press - m_p0) / molarDensity(); hrt[0] += presCorrect / RT(); }
void MineralEQ3::getIntEnergy_RT_ref(doublereal* urt) const { _updateThermo(); urt[0] = m_h0_RT - m_p0 / molarDensity() / RT(); }
void StoichSubstanceSSTP::getIntEnergy_RT(doublereal* urt) const { _updateThermo(); urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / (GasConstant * temperature()); }
doublereal StoichSubstance::intEnergy_mole() const { _updateThermo(); return GasConstant * temperature() * m_h0_RT[0] - m_p0 / molarDensity(); }
void LatticePhase::getParameters(int& n, doublereal* const c) const { c[0] = molarDensity(); n = 1; }
void StoichSubstance::getPartialMolarVolumes(doublereal* vbar) const { vbar[0] = 1.0 / molarDensity(); }
doublereal LatticePhase::enthalpy_mole() const { return RT() * mean_X(enthalpy_RT_ref()) + (pressure() - m_Pref)/molarDensity(); }
void MetalSHEelectrons::getIntEnergy_RT_ref(doublereal* urt) const { _updateThermo(); urt[0] = m_h0_RT - m_p0 / molarDensity() / RT(); }
doublereal IdealSolidSolnPhase::enthalpy_mole() const { doublereal htp = GasConstant * temperature() * mean_X(enthalpy_RT_ref()); return htp + (pressure() - m_Pref)/molarDensity(); }
void StoichSubstance::getStandardVolumes(doublereal* vol) const { vol[0] = 1.0 / molarDensity(); }
/* * Molar internal energy (J/kmol). * For an incompressible, * stoichiometric substance, the molar internal energy is * independent of pressure. Since the thermodynamic properties * are specified by giving the standard-state enthalpy, the * term \f$ P_0 \hat v\f$ is subtracted from the specified molar * enthalpy to compute the molar internal energy. */ void MineralEQ3::getIntEnergy_RT(doublereal* urt) const { _updateThermo(); doublereal RT = GasConstant * temperature(); doublereal PV = m_p0 / molarDensity(); urt[0] = m_h0_RT[0] - PV / RT; }
doublereal ConstDensityThermo::standardConcentration(int k) const { return molarDensity(); }
doublereal Phase::molarVolume() const { return 1.0/molarDensity(); }
doublereal ConstDensityThermo::logStandardConc(int k) const { return log(molarDensity()); }
void MetalSHEelectrons::getIntEnergy_RT_ref(doublereal* urt) const { _updateThermo(); doublereal RT = GasConstant * temperature(); urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / RT; }
void StoichSubstance::getEnthalpy_RT(doublereal* hrt) const { getEnthalpy_RT_ref(hrt); doublereal presCorrect = (m_press - m_p0) / molarDensity(); hrt[0] += presCorrect / RT(); }