ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / molecularDynamics / molecule / mdTools / temperatureAndPressure.H
blobdf182244d21dd7d05b11d519b236e9694ccb0d26
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 Global
25     temperatureAndPressure.H
27 Description
28     Accumulates values for temperature and pressure measurement, and
29     calculates and outputs the average values at output times.
30     Requires temperatureAndPressureVariables.H to be declared before the
31     timeloop.
33 \*---------------------------------------------------------------------------*/
35 accumulatedTotalLinearMomentum += singleStepTotalLinearMomentum;
37 accumulatedTotalMass += singleStepTotalMass;
39 accumulatedTotalLinearKE += singleStepTotalLinearKE;
41 accumulatedTotalAngularKE += singleStepTotalAngularKE;
43 accumulatedTotalPE += singleStepTotalPE;
45 accumulatedTotalrDotfSum += singleStepTotalrDotf;
47 accumulatedNMols += singleStepNMols;
49 accumulatedDOFs += singleStepDOFs;
51 if (runTime.outputTime())
53     if (accumulatedNMols)
54     {
55         Info<< "calculating averages" << endl;
57         averageTemperature =
58         (
59             2.0/(physicoChemical::k.value()*accumulatedDOFs)
60             *
61             (
62                 accumulatedTotalLinearKE + accumulatedTotalAngularKE
63                 -
64                 0.5*magSqr(accumulatedTotalLinearMomentum)/accumulatedTotalMass
65             )
66         );
68         averagePressure =
69         (
70             (
71                 (accumulatedNMols/nAveragingSteps)
72                *physicoChemical::k.value()*averageTemperature
73               + accumulatedTotalrDotfSum/(6.0*nAveragingSteps)
74             )
75             /
76             meshVolume
77         );
79         Info<< "----------------------------------------" << nl
80             << "Averaged properties" << nl
81             << "Average |velocity| = "
82             << mag(accumulatedTotalLinearMomentum)/accumulatedTotalMass << nl
83             << "Average temperature = " << averageTemperature << nl
84             << "Average pressure = " << averagePressure << nl
85             << "----------------------------------------" << endl;
86     }
87     else
88     {
89         Info<< "Not averaging temperature and pressure: "
90             << "no molecules in system" << endl;
91     }
93     accumulatedTotalLinearMomentum = vector::zero;
95     accumulatedTotalMass = 0.0;
97     accumulatedTotalLinearKE = 0.0;
99     accumulatedTotalAngularKE = 0.0;
101     accumulatedTotalPE = 0.0;
103     accumulatedTotalrDotfSum = 0.0;
105     accumulatedNMols = 0;
107     accumulatedDOFs = 0;
111 // ************************************************************************* //