From ddc0b20e9d7a06b52566b0bd22aff5bbd02bac8f Mon Sep 17 00:00:00 2001 From: Yeongdo Park Date: Tue, 30 Oct 2018 12:37:37 -0400 Subject: [PATCH] Particles now have their own gasHThermoPhysics object and diffusivityModel are fixed with gasHThermoPhysics Mixture --- diffusivityModel/Electron/Electron.C | 6 +-- diffusivityModel/Electron/Electron.H | 2 +- diffusivityModel/Ion/Ion.C | 16 +++---- diffusivityModel/Ion/Ion.H | 2 +- diffusivityModel/Neutral/Neutral.C | 43 ++++++++++--------- diffusivityModel/Neutral/Neutral.H | 2 +- diffusivityModel/Particle/Particle.C | 13 +++--- diffusivityModel/Particle/Particle.H | 8 +++- .../diffusivityModel/diffusivityModel.C | 31 +++++++++---- 9 files changed, 72 insertions(+), 51 deletions(-) diff --git a/diffusivityModel/Electron/Electron.C b/diffusivityModel/Electron/Electron.C index 379dd1c..b05298d 100644 --- a/diffusivityModel/Electron/Electron.C +++ b/diffusivityModel/Electron/Electron.C @@ -44,10 +44,10 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::Electron::Electron(const dictionary& dict) +Foam::Electron::Electron(const dictionary& thermoDict, const dictionary& tranDict) : - Particle(dict), - fitDict_(dict.subDict("fitCoefs")), + Particle(thermoDict, tranDict), + fitDict_(tranDict.subDict("fitCoefs")), collisionTargets_(fitDict_.lookup("species")), DejFitCoefs_(collisionTargets_.size()) { diff --git a/diffusivityModel/Electron/Electron.H b/diffusivityModel/Electron/Electron.H index 8488cff..4c763e5 100644 --- a/diffusivityModel/Electron/Electron.H +++ b/diffusivityModel/Electron/Electron.H @@ -95,7 +95,7 @@ public: // Constructors //- Construct from components - Electron(const dictionary& dict); + Electron(const dictionary& thermoDict, const dictionary& tranDict); //- Construct from Istream Electron(Istream&); diff --git a/diffusivityModel/Ion/Ion.C b/diffusivityModel/Ion/Ion.C index 0dd9bbc..68dd0b6 100644 --- a/diffusivityModel/Ion/Ion.C +++ b/diffusivityModel/Ion/Ion.C @@ -44,16 +44,16 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::Ion::Ion(const dictionary& dict) +Foam::Ion::Ion(const dictionary& thermoDict, const dictionary& tranDict) : - Particle(dict), - alpha_(dict.lookupOrDefault("dipolePolarizability", 0.0)), + Particle(thermoDict, tranDict), + alpha_(tranDict.lookupOrDefault("dipolePolarizability", 0.0)), C6_(0.0), - Zrot_(dict.lookupOrDefault("rotationalRelaxation", 0.0)), - n_(dict.lookupOrDefault("nStockmayer", 12)), - rctTarget_(dict.lookupOrDefault("rctTargets", hashedWordList())), - Arct_(dict.lookupOrDefault("Arct", scalarList())), - Brct_(dict.lookupOrDefault("Brct", scalarList())) + Zrot_(tranDict.lookupOrDefault("rotationalRelaxation", 0.0)), + n_(tranDict.lookupOrDefault("nStockmayer", 12)), + rctTarget_(tranDict.lookupOrDefault("rctTargets", hashedWordList())), + Arct_(tranDict.lookupOrDefault("Arct", scalarList())), + Brct_(tranDict.lookupOrDefault("Brct", scalarList())) { if (z() > 0) { diff --git a/diffusivityModel/Ion/Ion.H b/diffusivityModel/Ion/Ion.H index e047bd3..e5443fc 100644 --- a/diffusivityModel/Ion/Ion.H +++ b/diffusivityModel/Ion/Ion.H @@ -107,7 +107,7 @@ public: // Constructors //- Construct from components - Ion(const dictionary& dict); + Ion(const dictionary& thermoDict, const dictionary& tranDict); //- Construct from Istream Ion(Istream&); diff --git a/diffusivityModel/Neutral/Neutral.C b/diffusivityModel/Neutral/Neutral.C index ac700ea..1cf220a 100644 --- a/diffusivityModel/Neutral/Neutral.C +++ b/diffusivityModel/Neutral/Neutral.C @@ -1,4 +1,5 @@ /*---------------------------------------------------------------------------*\ + Particle(tranDict), ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | @@ -44,19 +45,19 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::Neutral::Neutral(const dictionary& dict) +Foam::Neutral::Neutral(const dictionary& thermoDict, const dictionary& tranDict) : - Particle(dict), - wellDepth_(dict.lookupOrDefault("wellDepth", 0.0)), - diameter_(dict.lookupOrDefault("diameter", 0.0)), - dipoleMoment_(dict.lookupOrDefault("dipoleMoment", 0.0)), - alpha_(dict.lookupOrDefault("dipolePolarizability", 0.0)), + Particle(thermoDict, tranDict), + wellDepth_(tranDict.lookupOrDefault("wellDepth", 0.0)), + diameter_(tranDict.lookupOrDefault("diameter", 0.0)), + dipoleMoment_(tranDict.lookupOrDefault("dipoleMoment", 0.0)), + alpha_(tranDict.lookupOrDefault("dipolePolarizability", 0.0)), alphaQ_(0.0), - C6_(dict.lookupOrDefault("dispersionCoef", 0.0)), - Zrot_(dict.lookupOrDefault("rotationalRelaxation", 0.0)) + C6_(tranDict.lookupOrDefault("dispersionCoef", 0.0)), + Zrot_(tranDict.lookupOrDefault("rotationalRelaxation", 0.0)) { - const entry* entryPtr = dict.lookupEntryPtr("tranlib", false, true); + const entry* entryPtr = tranDict.lookupEntryPtr("tranlib", false, true); if (entryPtr) { @@ -68,21 +69,21 @@ Foam::Neutral::Neutral(const dictionary& dict) alpha_ = tranlib[4]; Zrot_ = tranlib[5]; - dict.readIfPresent("wellDepth", wellDepth_); - dict.readIfPresent("diameter", diameter_); - dict.readIfPresent("dipoleMoment", dipoleMoment_); - dict.readIfPresent("dipolePolarizability", alpha_); - dict.readIfPresent("dispersionCoef", C6_); - dict.readIfPresent("rotationalRelaxation", Zrot_); + tranDict.readIfPresent("wellDepth", wellDepth_); + tranDict.readIfPresent("diameter", diameter_); + tranDict.readIfPresent("dipoleMoment", dipoleMoment_); + tranDict.readIfPresent("dipolePolarizability", alpha_); + tranDict.readIfPresent("dispersionCoef", C6_); + tranDict.readIfPresent("rotationalRelaxation", Zrot_); } else { - wellDepth_ = readScalar(dict.lookup("wellDepth")); - diameter_ = readScalar(dict.lookup("diameter")); - dipoleMoment_ = readScalar(dict.lookup("dipoleMoment")); - alpha_ = readScalar(dict.lookup("dipolePolarizability")); - C6_ = readScalar(dict.lookup("dispersionCoef")); - Zrot_ = readScalar(dict.lookup("rotationalRelaxation")); + wellDepth_ = readScalar(tranDict.lookup("wellDepth")); + diameter_ = readScalar(tranDict.lookup("diameter")); + dipoleMoment_ = readScalar(tranDict.lookup("dipoleMoment")); + alpha_ = readScalar(tranDict.lookup("dipolePolarizability")); + C6_ = readScalar(tranDict.lookup("dispersionCoef")); + Zrot_ = readScalar(tranDict.lookup("rotationalRelaxation")); } if (alpha_ > 0.0) diff --git a/diffusivityModel/Neutral/Neutral.H b/diffusivityModel/Neutral/Neutral.H index 4b1d4fb..af9b22f 100644 --- a/diffusivityModel/Neutral/Neutral.H +++ b/diffusivityModel/Neutral/Neutral.H @@ -106,7 +106,7 @@ public: // Constructors //- Construct from components - Neutral(const dictionary& dict); + Neutral(const dictionary& thermoDict, const dictionary& tranDict); //- Construct from Istream Neutral(Istream&); diff --git a/diffusivityModel/Particle/Particle.C b/diffusivityModel/Particle/Particle.C index 76522d7..81cc003 100644 --- a/diffusivityModel/Particle/Particle.C +++ b/diffusivityModel/Particle/Particle.C @@ -70,15 +70,16 @@ const Foam::scalar Foam::Particle::eps0 = constant::electromagnetic::epsilon0.va // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::Particle::Particle(const dictionary& dict) +Foam::Particle::Particle(const dictionary& thermoDict, const dictionary& tranDict) : - name_(dict["name"]), - W_(readScalar(dict["W"])), - z_(readScalar(dict["z"])) + name_(tranDict["name"]), + W_(readScalar(tranDict["W"])), + z_(readScalar(tranDict["z"])), + thermo_(thermoDict) { label geometry = 0; - const entry* entryPtr = dict.lookupEntryPtr("tranlib", false, true); + const entry* entryPtr = tranDict.lookupEntryPtr("tranlib", false, true); if (entryPtr) { @@ -87,7 +88,7 @@ Foam::Particle::Particle(const dictionary& dict) } else { - geometry = readLabel(dict.lookup("geometry")); + geometry = readLabel(tranDict.lookup("geometry")); } switch(geometry) diff --git a/diffusivityModel/Particle/Particle.H b/diffusivityModel/Particle/Particle.H index eab0793..65854ed 100644 --- a/diffusivityModel/Particle/Particle.H +++ b/diffusivityModel/Particle/Particle.H @@ -38,6 +38,7 @@ SourceFiles #include "word.H" #include "scalar.H" +#include "thermoPhysicsTypes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,6 +73,8 @@ public: NONLINEAR = 3 }; + //- The type of thermodynamics this mixture is instantiated for + typedef gasHThermoPhysics thermoType; protected: @@ -89,6 +92,9 @@ protected: //- Geometry Geometry geometry_; + //- Thermophysics Object + thermoType thermo_; + // Private Member Functions @@ -131,7 +137,7 @@ public: // Constructors //- Construct from components - Particle(const dictionary& dict); + Particle(const dictionary& thermoDict, const dictionary& tranDict); //- Construct from Istream Particle(Istream&); diff --git a/diffusivityModel/diffusivityModel/diffusivityModel.C b/diffusivityModel/diffusivityModel/diffusivityModel.C index a254469..94520ee 100644 --- a/diffusivityModel/diffusivityModel/diffusivityModel.C +++ b/diffusivityModel/diffusivityModel/diffusivityModel.C @@ -29,6 +29,9 @@ License #include "speciesTable.H" #include "volFieldsFwd.H" #include "scalarMatrices.H" +#include "multiComponentMixture.H" +#include "thermoPhysicsTypes.H" + #include "Particle.H" #include "Electron.H" #include "Neutral.H" @@ -323,8 +326,8 @@ Foam::diffusivityModel::diffusivityModel(const psiReactionThermo& thermo) thermo_.composition().Y(0).mesh(), dimensionedScalar("zero", dimForce/dimTime/dimTemperature, 0.0) ), - neutrals_(thermo_.composition().species().size()), ions_(thermo_.composition().species().size()), + neutrals_(thermo_.composition().species().size()), ecs_(thermo_.composition().species().size()), ens_(thermo_.composition().species().size()), nns_(thermo_.composition().species().size()*thermo_.composition().species().size()), @@ -332,6 +335,10 @@ Foam::diffusivityModel::diffusivityModel(const psiReactionThermo& thermo) cns_(thermo_.composition().species().size()*thermo_.composition().species().size()) { + typedef multiComponentMixture gasMix; + + const gasMix &mcm (dynamicCast(thermo_)); + const speciesTable &species_(thermo_.composition().species()); const volScalarField::Mesh &mesh = thermo_.composition().Y(0).mesh(); @@ -344,6 +351,14 @@ Foam::diffusivityModel::diffusivityModel(const psiReactionThermo& thermo) )() ); + dictionary thermos + ( + IFstream + ( + fileName(thermo_.lookup("foamChemistryThermoFile")).expand() + )() + ); + Switch readIons = false; Switch readNeutrals = false; @@ -356,16 +371,14 @@ Foam::diffusivityModel::diffusivityModel(const psiReactionThermo& thermo) const scalar Wi = thermo_.composition().W(i); const label zi = thermo_.composition().z(i); + dictionary thermoDict(thermos.subDict(species_[i])); + dictionary tranDict(transports.subDict(species_[i]).subDict("transport")); tranDict.add("name", namei); tranDict.add("W", Wi); tranDict.add("z", zi); - Particle p(tranDict); - - // Info << namei << endl << tranDict << endl; - // Info << p << endl; - // Info << scalarList(tranDict["tranlib"]) << endl; + const Particle::thermoType &thermoData(mcm.speciesData()[i]); // Electron if (species_[i] == "E-") @@ -377,7 +390,7 @@ Foam::diffusivityModel::diffusivityModel(const psiReactionThermo& thermo) << abort(FatalError); } - electron_.set(new Electron (tranDict)); + electron_.set(new Electron (thermoDict, tranDict)); } // Ions else if (zi != 0) @@ -391,7 +404,7 @@ Foam::diffusivityModel::diffusivityModel(const psiReactionThermo& thermo) readIons = true; - ions_.set(nIon, new Ion(tranDict)); + ions_.set(nIon, new Ion(thermoDict, tranDict)); nIon++; @@ -402,7 +415,7 @@ Foam::diffusivityModel::diffusivityModel(const psiReactionThermo& thermo) { readNeutrals = true; - neutrals_.set(nNeutral, new Neutral(tranDict)); + neutrals_.set(nNeutral, new Neutral(thermoDict, tranDict)); nNeutral++; }