• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

step/stepcore

gas.h

Go to the documentation of this file.
00001 /* This file is part of StepCore library.
00002    Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
00003 
00004    StepCore library is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 2 of the License, or
00007    (at your option) any later version.
00008 
00009    StepCore library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with StepCore; if not, write to the Free Software
00016    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 */
00018 
00023 #ifndef STEPCORE_GAS_H
00024 #define STEPCORE_GAS_H
00025 
00026 #include "particle.h"
00027 #include "world.h"
00028 #include <cmath>
00029 
00030 namespace StepCore {
00031 
00032 class GasParticle;
00033 class GasLJForce;
00034 class Gas;
00035 
00039 class GasParticle: public Particle
00040 {
00041     STEPCORE_OBJECT(GasParticle)
00042 
00043 public:
00045     explicit GasParticle(Vector2d position = Vector2d(0), Vector2d velocity = Vector2d(0), double mass = 1)
00046         : Particle(position, velocity, mass) {}
00047 };
00048 
00052 class GasLJForceErrors: public ObjectErrors
00053 {
00054     STEPCORE_OBJECT(GasLJForceErrors)
00055 
00056 public:
00058     GasLJForceErrors(Item* owner = 0)
00059         : ObjectErrors(owner), _depthVariance(0), _rminVariance(0) {}
00060 
00062     GasLJForce* gasLJForce() const;
00063 
00065     double depthVariance() const { return _depthVariance; }
00067     void setDepthVariance(double depthVariance) { _depthVariance = depthVariance; }
00068 
00070     double rminVariance() const { return _rminVariance; }
00072     void setRminVariance(double rminVariance) { _rminVariance = rminVariance; }
00073 
00074 protected:
00075     double _depthVariance;
00076     double _rminVariance;
00077     friend class GasLJForce;
00078 };
00079 
00099 class GasLJForce: public Item, public Force
00100 {
00101     STEPCORE_OBJECT(GasLJForce)
00102 
00103 public:
00105     explicit GasLJForce(double depth = 1, double rmin = 1, double cutoff = HUGE_VAL);
00106 
00107     void calcForce(bool calcVariances);
00108 
00110     double depth() const { return _depth; }
00112     void setDepth(double depth) { _depth = depth; calcABC(); }
00113 
00115     double rmin() const { return _rmin; }
00117     void setRmin(double rmin) { _rmin = rmin; calcABC(); }
00118 
00120     double cutoff() const { return _cutoff; }
00122     void setCutoff(double cutoff) { _cutoff = cutoff; calcABC(); }
00123 
00125     GasLJForceErrors* gasLJForceErrors() {
00126         return static_cast<GasLJForceErrors*>(objectErrors()); }
00127 
00128 protected:
00129     ObjectErrors* createObjectErrors() { return new GasLJForceErrors(this); }
00130     void calcABC();
00131 
00132     double _depth;
00133     double _rmin;
00134     double _cutoff;
00135     double _a, _b, _c;
00136     double _rmin6, _rmin12;
00137 };
00138 
00139 typedef std::vector<GasParticle*> GasParticleList;
00140 
00144 class GasErrors: public ObjectErrors
00145 {
00146     STEPCORE_OBJECT(GasErrors)
00147 
00148 public:
00150     GasErrors(Item* owner = 0)
00151         : ObjectErrors(owner) {}
00152 
00154     Gas* gas() const;
00155 
00156     double rectTemperatureVariance() const;
00157     double rectPressureVariance() const;
00158     Vector2d rectMeanVelocityVariance() const;
00159     double rectMeanKineticEnergyVariance() const;
00160     double rectMeanParticleMassVariance() const;
00161     double rectMassVariance() const;
00162 
00163 protected:
00164     friend class Gas;
00165 };
00166 
00170 class Gas: public ItemGroup
00171 {
00172     STEPCORE_OBJECT(Gas)
00173 
00174 public:
00175     Gas() : _measureRectCenter(0), _measureRectSize(1,1) {
00176         setColor(0xffff0000); objectErrors();
00177     }
00178 
00181     GasParticleList rectCreateParticles(int count,
00182                                 double mass, double temperature,
00183                                 const Vector2d& meanVelocity);
00184 
00185     void addParticles(const GasParticleList& particles);
00186 
00187     double rectVolume() const;
00188     double rectParticleCount() const;
00189     double rectConcentration() const;
00190     double rectTemperature() const;
00191     double rectPressure() const;
00192     Vector2d rectMeanVelocity() const;
00193     double rectMeanKineticEnergy() const;
00194     double rectMeanParticleMass() const;
00195     double rectMass() const;
00196 
00197     const Vector2d& measureRectCenter() const { return _measureRectCenter; }
00198     void setMeasureRectCenter(const Vector2d& measureRectCenter) { _measureRectCenter = measureRectCenter; }
00199 
00200     const Vector2d& measureRectSize() const { return _measureRectSize; }
00201     void setMeasureRectSize(const Vector2d& measureRectSize) { _measureRectSize = measureRectSize.cAbs(); }
00202 
00204     GasErrors* gasErrors() {
00205         return static_cast<GasErrors*>(objectErrors()); }
00206 
00207 protected:
00208     ObjectErrors* createObjectErrors() { return new GasErrors(this); }
00209 
00210     double randomUniform(double min=0, double max=1);
00211     double randomGauss(double mean=0, double deviation=1);
00212 
00213     Vector2d _measureRectCenter;
00214     Vector2d _measureRectSize;
00215 
00216     friend class GasErrors;
00217 };
00218 
00219 } // namespace StepCore
00220 
00221 #endif
00222 

step/stepcore

Skip menu "step/stepcore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal