Foam::chemistryReductionMethod<CompType, ThermoType>::chemistryReductionMethod ( const Foam::IOdictionary& dict, Foam::TDACChemistryModel<CompType, ThermoType>& chemistry ) : dict_(dict), coeffsDict_(dict.subDict("reduction")), active_(coeffsDict_.lookupOrDefault<Switch>("active", false)), log_(coeffsDict_.lookupOrDefault<Switch>("log", false)), chemistry_(chemistry), activeSpecies_(chemistry.nSpecie(), false), NsSimp_(chemistry.nSpecie()), nSpecie_(chemistry.nSpecie()), tolerance_(coeffsDict_.lookupOrDefault<scalar>("tolerance", 1e-4)) {}
Foam::DAC<CompType,ThermoType>::DAC ( const Foam::IOdictionary& dict, Foam::TDACChemistryModel<CompType, ThermoType>& chemistry ) : mechanismReduction<CompType, ThermoType>(dict, chemistry), searchInitSet_(this->coeffsDict_.subDict("initialSet").size()), zprime_(0), nbCLarge_(3), sC_(this->nSpecie_,0), sH_(this->nSpecie_,0), sO_(this->nSpecie_,0), sN_(this->nSpecie_,0), CO2Id_(-1), COId_(-1), HO2Id_(-1), H2OId_(-1), NOId_(-1), automaticSIS_(true), phiTol_(this->tolerance()), NOxThreshold_(1800), CO2Name_ ( dict.subDict("mechanismReduction").lookupOrDefault<word> ( "CO2Name","CO2" ) ), COName_ ( dict.subDict("mechanismReduction").lookupOrDefault<word> ( "COName","CO" ) ), HO2Name_ ( dict.subDict("mechanismReduction").lookupOrDefault<word> ( "HO2Name","HO2" ) ), H2OName_ ( dict.subDict("mechanismReduction").lookupOrDefault<word> ( "H2OName","H2O" ) ), NOName_ ( dict.subDict("mechanismReduction").lookupOrDefault<word> ( "NOName","NO" ) ), forceFuelInclusion_(false) { label j=0; dictionary initSet = this->coeffsDict_.subDict("initialSet"); for (label i=0; i<chemistry.nSpecie(); i++) { if (initSet.found(chemistry.Y()[i].name())) { searchInitSet_[j++]=i; } } if (j<searchInitSet_.size()) { FatalErrorIn("mechanismReduction") << searchInitSet_.size()-j << " species in the intial set is not in the mechanism " << initSet << abort(FatalError); } if (this->coeffsDict_.found("automaticSIS")) { automaticSIS_.readIfPresent("automaticSIS", this->coeffsDict_); } if (this->coeffsDict_.found("forceFuelInclusion")) { forceFuelInclusion_.readIfPresent ( "forceFuelInclusion",this->coeffsDict_ ); } if (this->coeffsDict_.found("phiTol")) { phiTol_ = readScalar(this->coeffsDict_.lookup("phiTol")); } if (this->coeffsDict_.found("NOxThreshold")) { NOxThreshold_ = readScalar(this->coeffsDict_.lookup("NOxThreshold")); } const List<List<chemkinReader::specieElement> >& specieComposition = chemistry.specieComp(); for (label i=0; i<this->nSpecie_; i++) { const List<chemkinReader::specieElement>& curSpecieComposition = specieComposition[i]; //for all elements in the current species forAll(curSpecieComposition,j) { const chemkinReader::specieElement& curElement = curSpecieComposition[j]; if (curElement.elementName == "C") { sC_[i] = curElement.nAtoms; } else if (curElement.elementName == "H") { sH_[i] = curElement.nAtoms; } else if (curElement.elementName == "O") { sO_[i] = curElement.nAtoms; } else if (curElement.elementName == "N") { sN_[i] = curElement.nAtoms; } else { Info<< "element not considered"<<endl; } } if (this->chemistry_.Y()[i].name() == CO2Name_) { CO2Id_ = i; } else if (this->chemistry_.Y()[i].name() == COName_) { COId_ = i; } else if (this->chemistry_.Y()[i].name() == HO2Name_) { HO2Id_ = i; } else if (this->chemistry_.Y()[i].name() == H2OName_) { H2OId_ = i; } else if (this->chemistry_.Y()[i].name() == NOName_) { NOId_ = i; } } if ((CO2Id_==-1 || COId_==-1 || HO2Id_==-1 || H2OId_==-1) && automaticSIS_) { FatalErrorIn("DAC.C::DAC") << "The name of the species used in automatic SIS are not found in " << " the mechanism. You should either set the name for CO2, CO, H2O" << " and HO2 properly or set automaticSIS to off " << abort(FatalError); } //To compute zprime, the fuel species should be specified. //According to the given mass fraction, an equivalent O/C ratio is computed if (automaticSIS_) { dictionary fuelDict; if (this->coeffsDict_.found("fuelSpecies")) { fuelDict = this->coeffsDict_.subDict("fuelSpecies"); fuelSpecies_ = fuelDict.toc(); if (fuelSpecies_.size() == 0) { FatalErrorIn("DAC.C::DAC") << "With automatic SIS, the fuel species should be " << "specified in the fuelSpecies subDict" << abort(FatalError); } } else { FatalErrorIn("DAC.C::DAC") << "With automatic SIS, the fuel species should be " << "specified in the fuelSpecies subDict" << abort(FatalError); } if (this->coeffsDict_.found("nbCLarge")) { nbCLarge_ = readLabel(fuelDict.lookup("nbCLarge")); } fuelSpeciesID_.setSize(fuelSpecies_.size()); fuelSpeciesProp_.setSize(fuelSpecies_.size()); scalar Mmtot(0.0); forAll(fuelSpecies_, i) { fuelSpeciesProp_[i] = readScalar(fuelDict.lookup(fuelSpecies_[i])); for (label j=0; j<this->nSpecie_; j++) { if (this->chemistry_.Y()[j].name() == fuelSpecies_[i]) { fuelSpeciesID_[i]=j; break; } } scalar curMm = this->chemistry_.specieThermo()[fuelSpeciesID_[i]].W(); Mmtot += fuelSpeciesProp_[i]/curMm; } Mmtot = 1.0/Mmtot; scalar nbC(0.0); scalar nbO(0.0); forAll(fuelSpecies_, i) { label curID = fuelSpeciesID_[i]; scalar curMm = this->chemistry_.specieThermo()[curID].W(); nbC += fuelSpeciesProp_[i]*Mmtot/curMm*sC_[curID]; nbO += fuelSpeciesProp_[i]*Mmtot/curMm*sO_[curID]; }