diff --git a/src/lagrangian/molecularDynamics/old/mdTools/averageMDFields.H b/src/lagrangian/molecularDynamics/old/mdTools/averageMDFields.H deleted file mode 100644 index a19febe07b..0000000000 --- a/src/lagrangian/molecularDynamics/old/mdTools/averageMDFields.H +++ /dev/null @@ -1,227 +0,0 @@ -if (runTime.outputTime()) -{ - /*-----------------------------------------------------------------------*\ - Number density - \*-----------------------------------------------------------------------*/ - - scalarField totalRhoN_sum(mesh.nCells(), 0.0); - - forAll(allSpeciesRhoN, rN) - { - allSpeciesRhoN[rN].internalField() = - allSpeciesN_RU[rN] - /mesh.cellVolumes() - /nAveragingSteps; - - totalRhoN_sum += allSpeciesRhoN[rN].internalField(); - } - - totalRhoN.internalField() = totalRhoN_sum; - - - /*-----------------------------------------------------------------------*\ - Mass density - \*-----------------------------------------------------------------------*/ - - scalarField totalRhoM_sum(mesh.nCells(), 0.0); - - forAll(allSpeciesRhoM, rM) - { - allSpeciesRhoM[rM].internalField() = - allSpeciesM_RU[rM] - /mesh.cellVolumes() - /nAveragingSteps; - - totalRhoM_sum += allSpeciesRhoM[rM].internalField(); - } - - totalRhoM.internalField() = totalRhoM_sum; - - /*-----------------------------------------------------------------------*\ - Bulk velocity - \*-----------------------------------------------------------------------*/ - - vectorField totalMomentum_sum(mesh.nCells(), vector::zero); - - scalarField totalMass_sum(mesh.nCells(), 0.0); - - forAll(allSpeciesVelocity, v) - { - // A check for 1/0 molecules is required. - - vectorField& singleSpeciesVelocity - ( - allSpeciesVelocity[v].internalField() - ); - - forAll(singleSpeciesVelocity, sSV) - { - if (allSpeciesN_RU[v][sSV]) - { - singleSpeciesVelocity[sSV] = - allSpeciesVelocitySum_RU[v][sSV] - /allSpeciesN_RU[v][sSV]; - - totalMomentum_sum[sSV] += - allSpeciesM_RU[v][sSV] - /allSpeciesN_RU[v][sSV] - *allSpeciesVelocitySum_RU[v][sSV]; - - totalMass_sum[sSV] += allSpeciesM_RU[v][sSV]; - } - else - { - singleSpeciesVelocity[sSV] = vector::zero; - } - } - } - - volVectorField::InternalField& itotalVelocity = - totalVelocity.internalField(); - - forAll(itotalVelocity, tV) - { - if (totalMass_sum[tV] > VSMALL) - { - itotalVelocity[tV] = totalMomentum_sum[tV]/totalMass_sum[tV]; - } - else - { - itotalVelocity[tV] = vector::zero; - } - } - - /*-----------------------------------------------------------------------*\ - Kinetic temperature - \*-----------------------------------------------------------------------*/ - - scalarField totalTemperatureVTerms_sum(mesh.nCells(), 0.0); - - scalarField totalN_sum(mesh.nCells(), 0.0); - - forAll(allSpeciesTemperature, t) - { - // A check for 1/0 molecules is required. - - scalarField& singleSpeciesTemp - ( - allSpeciesTemperature[t].internalField() - ); - - forAll(singleSpeciesTemp, sST) - { - if (allSpeciesN_RU[t][sST]) - { - singleSpeciesTemp[sST] = - allSpeciesM_RU[t][sST] - /allSpeciesN_RU[t][sST] - /(3.0 * moleculeCloud::kb * allSpeciesN_RU[t][sST]) - *( - allSpeciesVelocityMagSquaredSum_RU[t][sST] - - - ( - allSpeciesVelocitySum_RU[t][sST] - & - allSpeciesVelocitySum_RU[t][sST] - ) - /allSpeciesN_RU[t][sST] - ); - - totalTemperatureVTerms_sum[sST] += - allSpeciesM_RU[t][sST] - /allSpeciesN_RU[t][sST] - *( - allSpeciesVelocityMagSquaredSum_RU[t][sST] - - - ( - allSpeciesVelocitySum_RU[t][sST] - & - allSpeciesVelocitySum_RU[t][sST] - ) - /allSpeciesN_RU[t][sST] - ); - - totalN_sum[sST] += allSpeciesN_RU[t][sST]; - } - else - { - singleSpeciesTemp[sST] = 0.0; - } - } - } - - volScalarField::InternalField& itotalTemperature = - totalTemperature.internalField(); - - forAll(itotalTemperature, tT) - { - if (totalN_sum[tT] > 0) - { - itotalTemperature[tT] = - totalTemperatureVTerms_sum[tT] - /(3.0 * moleculeCloud::kb * totalN_sum[tT]); - } - else - { - itotalTemperature[tT] = 0.0; - } - } - - /*-----------------------------------------------------------------------*\ - Mean kinetic energy - \*-----------------------------------------------------------------------*/ - - scalarField totalKE_sum(mesh.nCells(), 0.0); - - forAll(allSpeciesMeanKE, mKE) - { - // A check for 1/0 molecules is required. - - scalarField& singleSpeciesMeanKE - ( - allSpeciesMeanKE[mKE].internalField() - ); - - forAll(singleSpeciesMeanKE, sSMKE) - { - if (allSpeciesN_RU[mKE][sSMKE]) - { - singleSpeciesMeanKE[sSMKE] = - allSpeciesM_RU[mKE][sSMKE] - /allSpeciesN_RU[mKE][sSMKE] - /(2.0*allSpeciesN_RU[mKE][sSMKE]) - *( - allSpeciesVelocityMagSquaredSum_RU[mKE][sSMKE] - ); - - totalKE_sum[sSMKE] += - allSpeciesM_RU[mKE][sSMKE] - /allSpeciesN_RU[mKE][sSMKE] - /2.0 - *( - allSpeciesVelocityMagSquaredSum_RU[mKE][sSMKE] - ); - } - else - { - singleSpeciesMeanKE[sSMKE] = 0.0; - } - } - } - - volScalarField::InternalField& itotalMeanKE = totalMeanKE.internalField(); - - forAll(itotalMeanKE, tMKE) - { - if (totalN_sum[tMKE] > 0) - { - itotalMeanKE[tMKE] = - totalKE_sum[tMKE] - /totalN_sum[tMKE]; - } - else - { - itotalMeanKE[tMKE] = 0.0; - } - } -} diff --git a/src/lagrangian/molecularDynamics/old/mdTools/calculateAutoCorrelationFunctions.H b/src/lagrangian/molecularDynamics/old/mdTools/calculateAutoCorrelationFunctions.H deleted file mode 100644 index 4b46bdd0df..0000000000 --- a/src/lagrangian/molecularDynamics/old/mdTools/calculateAutoCorrelationFunctions.H +++ /dev/null @@ -1,77 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -if (mesh.time().timeIndex() % vacf.sampleSteps() == 0) -{ - Field uVals(molecules.size()); - - label uV = 0; - - forAllConstIter(IDLList, molecules, mol) - { - uVals[uV++] = mol().U(); - } - - vacf.calculateCorrelationFunction(uVals); -} - -if (mesh.time().timeIndex() % pacf.sampleSteps() == 0) -{ - vector p = vector::zero; - - forAllConstIter(IDLList, molecules, mol) - { - p.x() += - mol().mass() * mol().U().y() * mol().U().z() - + 0.5*mol().rf().yz(); - - p.y() += - mol().mass() * mol().U().z() * mol().U().x() - + 0.5*mol().rf().zx(); - - p.z() += - mol().mass() * mol().U().x() * mol().U().y() - + 0.5*mol().rf().xy(); - } - - pacf.calculateCorrelationFunction(p); -} - -if (mesh.time().timeIndex() % hfacf.sampleSteps() == 0) -{ - vector s = vector::zero; - - forAllConstIter(IDLList, molecules, mol) - { - s += - ( - 0.5*mol().mass()*magSqr(mol().U()) - + mol().potentialEnergy() - )*mol().U() - + 0.5*(mol().rf() & mol().U()); - } - - hfacf.calculateCorrelationFunction(s); -} diff --git a/src/lagrangian/molecularDynamics/old/mdTools/calculateMDFields.H b/src/lagrangian/molecularDynamics/old/mdTools/calculateMDFields.H deleted file mode 100644 index af5c938da4..0000000000 --- a/src/lagrangian/molecularDynamics/old/mdTools/calculateMDFields.H +++ /dev/null @@ -1,23 +0,0 @@ -const List >& cellOccupancy = molecules.cellOccupancy(); - -forAll(cellOccupancy, cell) -{ - const List& molsInCell = cellOccupancy[cell]; - - forAll(molsInCell, mIC) - { - molecule* mol = molsInCell[mIC]; - - const label molId = mol->id(); - - const vector& molU = mol->U(); - - allSpeciesN_RU[molId][cell]++; - - allSpeciesM_RU[molId][cell] += mol->mass(); - - allSpeciesVelocitySum_RU[molId][cell] += molU; - - allSpeciesVelocityMagSquaredSum_RU[molId][cell] += molU & molU; - } -} diff --git a/src/lagrangian/molecularDynamics/old/mdTools/calculateTransportProperties.H b/src/lagrangian/molecularDynamics/old/mdTools/calculateTransportProperties.H deleted file mode 100644 index 72af8f3657..0000000000 --- a/src/lagrangian/molecularDynamics/old/mdTools/calculateTransportProperties.H +++ /dev/null @@ -1,81 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -if (writeVacf) -{ - OFstream vacfFile(runTime.path()/"vacf"); - - if (!vacf.writeAveraged(vacfFile)) - { - FatalErrorIn(args.executable()) - << "Failed writing to " - << vacfFile.name() - << abort(FatalError); - } -} - -Info<< "Diffusion coefficient = " - << vacf.integral() << endl; - -if (writePacf) -{ - OFstream pacfFile(runTime.path()/"pacf"); - - if (!pacf.writeAveraged(pacfFile)) - { - FatalErrorIn(args.executable()) - << "Failed writing to " - << pacfFile.name() - << abort(FatalError); - } -} - -Info<< "Viscosity = " - << pacf.integral()/averageTemperature/moleculeCloud::kb/meshVolume - << endl; - -if (writeHFacf) -{ - OFstream hfacfFile - ( - runTime.path()/ + "hfacf" - ); - - if (!hfacf.writeAveraged(hfacfFile)) - { - FatalErrorIn(args.executable()) - << "Failed writing to " - << hfacfFile.name() - << abort(FatalError); - } -} - -Info<< "Thermal conductivity = " - << hfacf.integral() - /averageTemperature - /averageTemperature - /moleculeCloud::kb - / meshVolume - << endl; diff --git a/src/lagrangian/molecularDynamics/old/mdTools/createAutoCorrelationFunctions.H b/src/lagrangian/molecularDynamics/old/mdTools/createAutoCorrelationFunctions.H deleted file mode 100644 index 55fbe14bbc..0000000000 --- a/src/lagrangian/molecularDynamics/old/mdTools/createAutoCorrelationFunctions.H +++ /dev/null @@ -1,98 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -Info << nl << "Creating autocorrelation functions." << endl; - -IOdictionary mdTransportProperitesDict -( - IOobject - ( - "mdTransportProperitesDict", - mesh.time().system(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false - ) -); - -const dictionary& autocorrelationFunctionDict -( - mdTransportProperitesDict.subDict("autocorrelationFunctions") -); - -//- Velocity autocorrelation function - -Info << tab << "velocty" << endl; - -const dictionary& velocityACFDict -( - autocorrelationFunctionDict.subDict("velocity") -); - -correlationFunction vacf -( - mesh, - velocityACFDict, - molecules.size() -); - -bool writeVacf(Switch(velocityACFDict.lookup("writeFile"))); - -//- Pressure autocorrelation function - -Info << tab << "pressure" << endl; - -const dictionary& pressureACFDict -( - autocorrelationFunctionDict.subDict("pressure") -); - -correlationFunction pacf -( - mesh, - pressureACFDict, - 1 -); - -bool writePacf(Switch(pressureACFDict.lookup("writeFile"))); - -//- Heat flux autocorrelation function - -Info << tab << "heat flux" << endl; - -const dictionary& heatFluxACFDict -( - autocorrelationFunctionDict.subDict("heatFlux") -); - -correlationFunction hfacf -( - mesh, - heatFluxACFDict, - 1 -); - -bool writeHFacf(Switch(heatFluxACFDict.lookup("writeFile"))); diff --git a/src/lagrangian/molecularDynamics/old/mdTools/createMDFields.H b/src/lagrangian/molecularDynamics/old/mdTools/createMDFields.H deleted file mode 100644 index 6d6617d652..0000000000 --- a/src/lagrangian/molecularDynamics/old/mdTools/createMDFields.H +++ /dev/null @@ -1,324 +0,0 @@ -// Fields for data gathering - -List< scalarField > allSpeciesN_RU -( - molecules.potential().nIds(), - scalarField (mesh.nCells(), 0.0) -); - -List< scalarField > allSpeciesM_RU -( - molecules.potential().nIds(), - scalarField (mesh.nCells(), 0.0) -); - -List< vectorField > allSpeciesVelocitySum_RU -( - molecules.potential().nIds(), - vectorField (mesh.nCells(), vector::zero) -); - -List< scalarField > allSpeciesVelocityMagSquaredSum_RU -( - molecules.potential().nIds(), - scalarField (mesh.nCells(), 0.0) -); - -// Geometric Fields for IO - -Info << nl << "Creating fields." << endl; - -/*---------------------------------------------------------------------------*\ - Number density -\*---------------------------------------------------------------------------*/ - -PtrList allSpeciesRhoN -( - molecules.potential().nIds() -); - -forAll(allSpeciesRhoN, rN) -{ - Info<< " Creating number density field for " - << molecules.potential().idList()[rN] << endl; - - allSpeciesRhoN.set - ( - rN, - new volScalarField - ( - IOobject - ( - "rhoN_" + molecules.potential().idList()[rN], - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimless/dimVolume, - "zeroGradient" - ) - ); - allSpeciesRhoN[rN].internalField() = scalarField (mesh.nCells(), 0.0); - allSpeciesRhoN[rN].correctBoundaryConditions(); -} - -Info << " Creating total number density field" << endl; - -volScalarField totalRhoN -( - IOobject - ( - "rhoN_total", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimless/dimVolume, - "zeroGradient" -); -totalRhoN.internalField() = scalarField (mesh.nCells(), 0.0); -totalRhoN.correctBoundaryConditions(); - -/*---------------------------------------------------------------------------*\ - Mass density -\*---------------------------------------------------------------------------*/ - -PtrList allSpeciesRhoM -( - molecules.potential().nIds() -); - -forAll(allSpeciesRhoM, rM) -{ - Info<< " Creating mass density field for " - << molecules.potential().idList()[rM] << endl; - - allSpeciesRhoM.set - ( - rM, - new volScalarField - ( - IOobject - ( - "rhoM_" + molecules.potential().idList()[rM], - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimMass/dimVolume, - "zeroGradient" - ) - ); - allSpeciesRhoM[rM].internalField() = scalarField (mesh.nCells(), 0.0); - allSpeciesRhoM[rM].correctBoundaryConditions(); -} - -Info << " Creating total mass density field" << endl; - -volScalarField totalRhoM -( - IOobject - ( - "rhoM_total", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimMass/dimVolume, - "zeroGradient" -); -totalRhoM.internalField() = scalarField (mesh.nCells(), 0.0); -totalRhoM.correctBoundaryConditions(); - -/*---------------------------------------------------------------------------*\ - Bulk velocity -\*---------------------------------------------------------------------------*/ - -PtrList allSpeciesVelocity -( - molecules.potential().nIds() -); - -forAll(allSpeciesVelocity, v) -{ - Info<< " Creating velocity field for " - << molecules.potential().idList()[v] << endl; - - allSpeciesVelocity.set - ( - v, - new volVectorField - ( - IOobject - ( - "velocity_" + molecules.potential().idList()[v], - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimVelocity, - "zeroGradient" - ) - ); - allSpeciesVelocity[v].internalField() = - vectorField (mesh.nCells(), vector::zero); - allSpeciesVelocity[v].correctBoundaryConditions(); -} - -Info << " Creating total velocity field" << endl; - -// volVectorField totalVelocity -// ( -// IOobject -// ( -// "velocity_total", -// runTime.timeName(), -// mesh, -// IOobject::NO_READ, -// IOobject::AUTO_WRITE -// ), -// mesh, -// dimVelocity, -// "zeroGradient" -// ); -// totalVelocity.internalField() = vectorField (mesh.nCells(), vector::zero); -// totalVelocity.correctBoundaryConditions(); - - -volVectorField totalVelocity - -( - IOobject - ( - - "velocity_total", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - - ), - mesh, - dimensionedVector("zero", dimVelocity, vector::zero) -); - -/*---------------------------------------------------------------------------*\ - Kinetic temperature -\*---------------------------------------------------------------------------*/ - -PtrList allSpeciesTemperature -( - molecules.potential().nIds() -); - -forAll(allSpeciesTemperature, t) -{ - Info<< " Creating temperature field for " - << molecules.potential().idList()[t] << endl; - - allSpeciesTemperature.set - ( - t, - new volScalarField - ( - IOobject - ( - "temperature_" + molecules.potential().idList()[t], - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimTemperature, - "zeroGradient" - ) - ); - allSpeciesTemperature[t].internalField() = scalarField (mesh.nCells(), 0.0); - allSpeciesTemperature[t].correctBoundaryConditions(); -} - -Info << " Creating total temperature field" << endl; - -volScalarField totalTemperature -( - IOobject - ( - "temperature_total", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimTemperature, - "zeroGradient" -); -totalTemperature.internalField() = scalarField (mesh.nCells(), 0.0); -totalTemperature.correctBoundaryConditions(); - -/*---------------------------------------------------------------------------*\ - Mean kinetic energy -\*---------------------------------------------------------------------------*/ - - -PtrList allSpeciesMeanKE -( - molecules.potential().nIds() -); - -forAll(allSpeciesMeanKE, mKE) -{ - Info<< " Creating mean kinetic energy field for " - << molecules.potential().idList()[mKE] << endl; - - allSpeciesMeanKE.set - ( - mKE, - new volScalarField - ( - IOobject - ( - "meanKE_" + molecules.potential().idList()[mKE], - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimensionSet(1, 2, -2, 0, 0, 0, 0), - "zeroGradient" - ) - ); - allSpeciesMeanKE[mKE].internalField() = scalarField (mesh.nCells(), 0.0); - allSpeciesMeanKE[mKE].correctBoundaryConditions(); -} - -Info << " Creating total mean kinetic energy field" << endl; - -volScalarField totalMeanKE -( - IOobject - ( - "meanKE_total", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimensionSet(1, 2, -2, 0, 0, 0, 0), - "zeroGradient" -); -totalMeanKE.internalField() = scalarField (mesh.nCells(), 0.0); -totalMeanKE.correctBoundaryConditions(); diff --git a/src/lagrangian/molecularDynamics/old/mdTools/createRefUnits.H b/src/lagrangian/molecularDynamics/old/mdTools/createRefUnits.H deleted file mode 100644 index c1e558b221..0000000000 --- a/src/lagrangian/molecularDynamics/old/mdTools/createRefUnits.H +++ /dev/null @@ -1,22 +0,0 @@ -reducedUnits refUnits; - -IOobject reducedUnitsDictIOobject -( - "reducedUnitsDict", - runTime.system(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE -); - -if (reducedUnitsDictIOobject.headerOk()) -{ - Info<< nl - << "Reading reference quantities from reducedUnitsDict file." << endl; - - IOdictionary reducedUnitsDict(reducedUnitsDictIOobject); - - refUnits.setRefValues(reducedUnitsDict); -} - -Info << refUnits << endl; diff --git a/src/lagrangian/molecularDynamics/old/mdTools/md.H b/src/lagrangian/molecularDynamics/old/mdTools/md.H deleted file mode 100644 index 9a079764ae..0000000000 --- a/src/lagrangian/molecularDynamics/old/mdTools/md.H +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef md_H -#define md_H - #include "potential.H" - #include "moleculeCloud.H" - #include "correlationFunction.H" - #include "distribution.H" - #include "reducedUnits.H" -#endif - diff --git a/src/lagrangian/molecularDynamics/old/mdTools/meanMomentumEnergyAndNMols.H b/src/lagrangian/molecularDynamics/old/mdTools/meanMomentumEnergyAndNMols.H deleted file mode 100644 index ae117cafc5..0000000000 --- a/src/lagrangian/molecularDynamics/old/mdTools/meanMomentumEnergyAndNMols.H +++ /dev/null @@ -1,180 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Global - meanMomentumEnergyAndNMols.H - -Description - Calculates and prints the mean momentum and energy in the system - and the number of molecules. - -\*---------------------------------------------------------------------------*/ - - -vector singleStepTotalLinearMomentum(vector::zero); - -vector singleStepTotalAngularMomentum(vector::zero); - -scalar singleStepMaxVelocityMag = 0.0; - -scalar singleStepTotalMass = 0.0; - -scalar singleStepTotalLinearKE = 0.0; - -scalar singleStepTotalAngularKE = 0.0; - -scalar singleStepTotalPE = 0.0; - -scalar singleStepTotalrDotf = 0.0; - -//vector singleStepCentreOfMass(vector::zero); - -label singleStepNMols = molecules.size(); - -label singleStepDOFs = 0; - -{ - forAllConstIter(IDLList, molecules, mol) - { - const label molId = mol().id(); - - scalar molMass(molecules.constProps(molId).mass()); - - singleStepTotalMass += molMass; - - //singleStepCentreOfMass += mol().position()*molMass; - } - - // if (singleStepNMols) - // { - // singleStepCentreOfMass /= singleStepTotalMass; - // } - - forAllConstIter(IDLList, molecules, mol) - { - const label molId = mol().id(); - - const molecule::constantProperties cP(molecules.constProps(molId)); - - scalar molMass(cP.mass()); - - const diagTensor& molMoI(cP.momentOfInertia()); - - const vector& molV(mol().v()); - - const vector& molOmega(inv(molMoI) & mol().pi()); - - vector molPiGlobal = mol().Q() & mol().pi(); - - singleStepTotalLinearMomentum += molV * molMass; - - singleStepTotalAngularMomentum += molPiGlobal; - //+((mol().position() - singleStepCentreOfMass) ^ (molV * molMass)); - - if (mag(molV) > singleStepMaxVelocityMag) - { - singleStepMaxVelocityMag = mag(molV); - } - - singleStepTotalLinearKE += 0.5*molMass*magSqr(molV); - - singleStepTotalAngularKE += 0.5*(molOmega & molMoI & molOmega); - - singleStepTotalPE += mol().potentialEnergy(); - - singleStepTotalrDotf += tr(mol().rf()); - - singleStepDOFs += cP.degreesOfFreedom(); - } -} - -if (Pstream::parRun()) -{ - reduce(singleStepTotalLinearMomentum, sumOp()); - - reduce(singleStepTotalAngularMomentum, sumOp()); - - reduce(singleStepMaxVelocityMag, maxOp()); - - reduce(singleStepTotalMass, sumOp()); - - reduce(singleStepTotalLinearKE, sumOp()); - - reduce(singleStepTotalAngularKE, sumOp()); - - reduce(singleStepTotalPE, sumOp()); - - reduce(singleStepTotalrDotf, sumOp()); - - reduce(singleStepNMols, sumOp