Esempio n. 1
0
 doublereal LatticePhase::
 enthalpy_mole() const {
   doublereal p0 = m_spthermo->refPressure();
   return GasConstant * temperature() * 
     mean_X(&enthalpy_RT_ref()[0]) 
     + (pressure() - p0)/molarDensity();
 }
Esempio n. 2
0
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;
}
Esempio n. 3
0
void IdealGasPhase::getStandardVolumes(doublereal* vol) const
{
    double tmp = 1.0 / molarDensity();
    for (size_t k = 0; k < m_kk; k++) {
        vol[k] = tmp;
    }
}
Esempio n. 4
0
void IdealGasPhase::getPartialMolarVolumes(doublereal* vbar) const
{
    double vol = 1.0 / molarDensity();
    for (size_t k = 0; k < m_kk; k++) {
        vbar[k] = vol;
    }
}
Esempio n. 5
0
  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;
    }
  }
Esempio n. 6
0
 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;
   }
 }
Esempio n. 7
0
 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();
 }
Esempio n. 8
0
 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;
     }
 }
Esempio n. 9
0
 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();
     }
 }
Esempio n. 10
0
 doublereal ConstDensityThermo::intEnergy_mole() const {
     doublereal p0 = m_spthermo->refPressure();
     return GasConstant * temperature() * 
         mean_X(&enthalpy_RT()[0]) 
         - p0/molarDensity();
 }
Esempio n. 11
0
void StoichSubstance::getIntEnergy_RT_ref(doublereal* urt) const
{
    _updateThermo();
    urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
}
Esempio n. 12
0
doublereal StoichSubstance::enthalpy_mole() const
{
    return intEnergy_mole() + m_press / molarDensity();
}
Esempio n. 13
0
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, &timestep, &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;
}
Esempio n. 14
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;
 }
Esempio n. 15
0
void MineralEQ3::getEnthalpy_RT(doublereal* hrt) const
{
    getEnthalpy_RT_ref(hrt);
    doublereal presCorrect = (m_press - m_p0) / molarDensity();
    hrt[0] += presCorrect / RT();
}
Esempio n. 16
0
void MineralEQ3::getIntEnergy_RT_ref(doublereal* urt) const
{
    _updateThermo();
    urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
}
Esempio n. 17
0
void StoichSubstanceSSTP::getIntEnergy_RT(doublereal* urt) const
{
    _updateThermo();
    urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / (GasConstant * temperature());
}
Esempio n. 18
0
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;
}
Esempio n. 20
0
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();
}
Esempio n. 22
0
void MetalSHEelectrons::getIntEnergy_RT_ref(doublereal* urt) const
{
    _updateThermo();
    urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
}
Esempio n. 23
0
doublereal IdealSolidSolnPhase::enthalpy_mole() const
{
    doublereal htp = GasConstant * temperature() * mean_X(enthalpy_RT_ref());
    return htp + (pressure() - m_Pref)/molarDensity();
}
Esempio n. 24
0
void StoichSubstance::getStandardVolumes(doublereal* vol) const
{
    vol[0] = 1.0 / molarDensity();
}
Esempio n. 25
0
 /*
  * 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;
 }
Esempio n. 26
0
 doublereal ConstDensityThermo::standardConcentration(int k) const {
     return molarDensity();
 }
Esempio n. 27
0
doublereal Phase::molarVolume() const
{
    return 1.0/molarDensity();
}
Esempio n. 28
0
 doublereal ConstDensityThermo::logStandardConc(int k) const {
     return log(molarDensity());
 }
Esempio n. 29
0
void MetalSHEelectrons::getIntEnergy_RT_ref(doublereal* urt) const
{
    _updateThermo();
    doublereal RT = GasConstant * temperature();
    urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / RT;
}
Esempio n. 30
0
void StoichSubstance::getEnthalpy_RT(doublereal* hrt) const
{
    getEnthalpy_RT_ref(hrt);
    doublereal presCorrect = (m_press - m_p0) / molarDensity();
    hrt[0] += presCorrect / RT();
}