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

step/stepcore

  • sources
  • kde-4.14
  • kdeedu
  • step
  • stepcore
gas.h
Go to the documentation of this file.
1 /* This file is part of StepCore library.
2  Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
3 
4  StepCore library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  StepCore library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with StepCore; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
23 #ifndef STEPCORE_GAS_H
24 #define STEPCORE_GAS_H
25 
26 #include "particle.h"
27 #include "world.h"
28 #include <cmath>
29 
30 namespace StepCore {
31 
32 class GasParticle;
33 class GasLJForce;
34 class Gas;
35 
39 class GasParticle: public Particle
40 {
41  STEPCORE_OBJECT(GasParticle)
42 
43 public:
45  explicit GasParticle(Vector2d position = Vector2d::Zero(), Vector2d velocity = Vector2d::Zero(), double mass = 1)
46  : Particle(position, velocity, mass) {}
47 };
48 
52 class GasLJForceErrors: public ObjectErrors
53 {
54  STEPCORE_OBJECT(GasLJForceErrors)
55 
56 public:
58  GasLJForceErrors(Item* owner = 0)
59  : ObjectErrors(owner), _depthVariance(0), _rminVariance(0) {}
60 
62  GasLJForce* gasLJForce() const;
63 
65  double depthVariance() const { return _depthVariance; }
67  void setDepthVariance(double depthVariance) { _depthVariance = depthVariance; }
68 
70  double rminVariance() const { return _rminVariance; }
72  void setRminVariance(double rminVariance) { _rminVariance = rminVariance; }
73 
74 protected:
75  double _depthVariance;
76  double _rminVariance;
77  friend class GasLJForce;
78 };
79 
99 class GasLJForce: public Item, public Force
100 {
101  STEPCORE_OBJECT(GasLJForce)
102 
103 public:
105  explicit GasLJForce(double depth = 1, double rmin = 1, double cutoff = HUGE_VAL);
106 
107  void calcForce(bool calcVariances);
108 
110  double depth() const { return _depth; }
112  void setDepth(double depth) { _depth = depth; calcABC(); }
113 
115  double rmin() const { return _rmin; }
117  void setRmin(double rmin) { _rmin = rmin; calcABC(); }
118 
120  double cutoff() const { return _cutoff; }
122  void setCutoff(double cutoff) { _cutoff = cutoff; calcABC(); }
123 
125  GasLJForceErrors* gasLJForceErrors() {
126  return static_cast<GasLJForceErrors*>(objectErrors()); }
127 
128 protected:
129  ObjectErrors* createObjectErrors() { return new GasLJForceErrors(this); }
130  void calcABC();
131 
132  double _depth;
133  double _rmin;
134  double _cutoff;
135  double _a, _b, _c;
136  double _rmin6, _rmin12;
137 };
138 
139 typedef std::vector<GasParticle*> GasParticleList;
140 
144 class GasErrors: public ObjectErrors
145 {
146  STEPCORE_OBJECT(GasErrors)
147 
148 public:
150  GasErrors(Item* owner = 0)
151  : ObjectErrors(owner) {}
152 
154  Gas* gas() const;
155 
156  double rectTemperatureVariance() const;
157  double rectPressureVariance() const;
158  Vector2d rectMeanVelocityVariance() const;
159  double rectMeanKineticEnergyVariance() const;
160  double rectMeanParticleMassVariance() const;
161  double rectMassVariance() const;
162 
163 protected:
164  friend class Gas;
165 };
166 
170 class Gas: public ItemGroup
171 {
172  STEPCORE_OBJECT(Gas)
173 
174 public:
175  Gas() : _measureRectCenter(0,0), _measureRectSize(1,1) {
176  setColor(0xffff0000); objectErrors();
177  }
178 
181  GasParticleList rectCreateParticles(int count,
182  double mass, double temperature,
183  const Vector2d& meanVelocity);
184 
185  void addParticles(const GasParticleList& particles);
186 
187  double rectVolume() const;
188  double rectParticleCount() const;
189  double rectConcentration() const;
190  double rectTemperature() const;
191  double rectPressure() const;
192  Vector2d rectMeanVelocity() const;
193  double rectMeanKineticEnergy() const;
194  double rectMeanParticleMass() const;
195  double rectMass() const;
196 
197  const Vector2d& measureRectCenter() const { return _measureRectCenter; }
198  void setMeasureRectCenter(const Vector2d& measureRectCenter) { _measureRectCenter = measureRectCenter; }
199 
200  const Vector2d& measureRectSize() const { return _measureRectSize; }
201  void setMeasureRectSize(const Vector2d& measureRectSize) { _measureRectSize = measureRectSize.cwise().abs(); }
202 
204  GasErrors* gasErrors() {
205  return static_cast<GasErrors*>(objectErrors()); }
206 
207 protected:
208  ObjectErrors* createObjectErrors() { return new GasErrors(this); }
209 
210  double randomUniform(double min=0, double max=1);
211  double randomGauss(double mean=0, double deviation=1);
212 
213  Vector2d _measureRectCenter;
214  Vector2d _measureRectSize;
215 
216  friend class GasErrors;
217 };
218 
219 } // namespace StepCore
220 
221 #endif
222 
StepCore::Particle::mass
double mass() const
Get mass of the particle.
Definition: particle.h:138
StepCore::Gas
Gas - a group of several GasParticle and a force.
Definition: gas.h:170
StepCore::GasErrors::rectTemperatureVariance
double rectTemperatureVariance() const
Definition: gas.cc:457
StepCore::GasLJForce::_rmin12
double _rmin12
Definition: gas.h:136
StepCore::Gas::Gas
Gas()
Definition: gas.h:175
StepCore::GasParticle
Gas particle.
Definition: gas.h:39
StepCore::GasLJForce::cutoff
double cutoff() const
Get cut-off distance.
Definition: gas.h:120
StepCore::GasLJForceErrors::depthVariance
double depthVariance() const
Get depth variance.
Definition: gas.h:65
StepCore::GasErrors
Errors object for Gas.
Definition: gas.h:144
StepCore::Vector2d
Eigen::Vector2d Vector2d
Two-dimensional vector with double components.
Definition: vector.h:29
StepCore::GasErrors::rectMeanKineticEnergyVariance
double rectMeanKineticEnergyVariance() const
Definition: gas.cc:398
StepCore::Gas::_measureRectCenter
Vector2d _measureRectCenter
Definition: gas.h:213
StepCore::GasLJForceErrors::_rminVariance
double _rminVariance
Definition: gas.h:76
StepCore::Gas::addParticles
void addParticles(const GasParticleList &particles)
Definition: gas.cc:203
StepCore::Gas::GasErrors
friend class GasErrors
Definition: gas.h:216
StepCore::Gas::rectCreateParticles
GasParticleList rectCreateParticles(int count, double mass, double temperature, const Vector2d &meanVelocity)
Creates particles with given temperature.
Definition: gas.cc:183
StepCore::Gas::rectVolume
double rectVolume() const
Definition: gas.cc:158
StepCore::Gas::rectConcentration
double rectConcentration() const
Definition: gas.cc:320
StepCore::GasParticle::GasParticle
GasParticle(Vector2d position=Vector2d::Zero(), Vector2d velocity=Vector2d::Zero(), double mass=1)
Constructs a GasParticle.
Definition: gas.h:45
StepCore::GasErrors::gas
Gas * gas() const
Get owner as Gas.
Definition: gas.cc:153
StepCore::GasLJForce::_a
double _a
Definition: gas.h:135
StepCore::GasErrors::rectMassVariance
double rectMassVariance() const
Definition: gas.cc:299
StepCore::GasLJForce::setDepth
void setDepth(double depth)
Set depth of the potential.
Definition: gas.h:112
world.h
Item, Body, Force and Tool interfaces, World class.
StepCore::Gas::rectTemperature
double rectTemperature() const
Definition: gas.cc:433
StepCore::GasLJForce::GasLJForce
GasLJForce(double depth=1, double rmin=1, double cutoff=HUGE_VAL)
Constructs GasLJForce.
StepCore::GasLJForceErrors::setDepthVariance
void setDepthVariance(double depthVariance)
Set depth variance.
Definition: gas.h:67
StepCore::GasLJForce::_cutoff
double _cutoff
Definition: gas.h:134
StepCore::Item::setColor
void setColor(Color color)
Set item color (for use in GUI)
Definition: world.h:112
StepCore::Gas::measureRectCenter
const Vector2d & measureRectCenter() const
Definition: gas.h:197
StepCore::Gas::rectMeanKineticEnergy
double rectMeanKineticEnergy() const
Definition: gas.cc:376
StepCore::Gas::rectMeanVelocity
Vector2d rectMeanVelocity() const
Definition: gas.cc:325
StepCore::GasLJForceErrors::_depthVariance
double _depthVariance
Definition: gas.h:75
StepCore::Gas::setMeasureRectSize
void setMeasureRectSize(const Vector2d &measureRectSize)
Definition: gas.h:201
StepCore::Gas::gasErrors
GasErrors * gasErrors()
Get (and possibly create) GasErrors object.
Definition: gas.h:204
StepCore::Gas::_measureRectSize
Vector2d _measureRectSize
Definition: gas.h:214
StepCore::GasLJForce
Lennard-Jones force with cut-off which acts between particles in the Gas.
Definition: gas.h:99
StepCore::Item
The root class for any world items (bodies and forces)
Definition: world.h:69
StepCore::GasLJForceErrors::GasLJForceErrors
GasLJForceErrors(Item *owner=0)
Constructs GasLJForceErrors.
Definition: gas.h:58
StepCore::GasLJForce::_c
double _c
Definition: gas.h:135
StepCore::GasErrors::rectPressureVariance
double rectPressureVariance() const
Definition: gas.cc:519
StepCore::GasErrors::rectMeanVelocityVariance
Vector2d rectMeanVelocityVariance() const
Definition: gas.cc:347
StepCore::GasLJForceErrors::rminVariance
double rminVariance() const
Get rmin variance.
Definition: gas.h:70
StepCore::GasLJForce::_rmin6
double _rmin6
Definition: gas.h:136
StepCore::GasParticleList
std::vector< GasParticle * > GasParticleList
Definition: gas.h:139
StepCore::GasLJForce::depth
double depth() const
Get depth of the potential.
Definition: gas.h:110
StepCore::ObjectErrors
Base class for all errors objects.
Definition: world.h:49
StepCore::GasLJForceErrors
Errors object for GasLJForce.
Definition: gas.h:52
StepCore::GasErrors::rectMeanParticleMassVariance
double rectMeanParticleMassVariance() const
Definition: gas.cc:251
StepCore::Gas::randomUniform
double randomUniform(double min=0, double max=1)
Definition: gas.cc:163
StepCore::ItemGroup
Groups several items together.
Definition: world.h:309
StepCore::GasLJForce::calcForce
void calcForce(bool calcVariances)
Calculate force.
Definition: gas.cc:105
StepCore::Gas::rectParticleCount
double rectParticleCount() const
Definition: gas.cc:211
StepCore::GasLJForce::calcABC
void calcABC()
Definition: gas.cc:96
StepCore::Force
Interface for forces.
Definition: world.h:199
StepCore::Particle
Particle with mass.
Definition: particle.h:103
StepCore::GasLJForce::setCutoff
void setCutoff(double cutoff)
Set cut-off distance.
Definition: gas.h:122
StepCore::GasLJForce::_depth
double _depth
Definition: gas.h:132
StepCore::Item::objectErrors
ObjectErrors * objectErrors()
Get existing ObjectErrors or try to create it.
Definition: world.cc:67
StepCore::GasLJForceErrors::setRminVariance
void setRminVariance(double rminVariance)
Set rmin variance.
Definition: gas.h:72
StepCore::GasLJForce::_rmin
double _rmin
Definition: gas.h:133
StepCore::GasLJForce::_b
double _b
Definition: gas.h:135
StepCore::Gas::measureRectSize
const Vector2d & measureRectSize() const
Definition: gas.h:200
StepCore::Gas::rectMeanParticleMass
double rectMeanParticleMass() const
Definition: gas.cc:229
particle.h
Particle and ChargedParticle classes.
StepCore::GasLJForce::setRmin
void setRmin(double rmin)
Set distance at which the interparticle force is zero.
Definition: gas.h:117
StepCore::GasLJForce::gasLJForceErrors
GasLJForceErrors * gasLJForceErrors()
Get (and possibly create) GasLJForceErrors object.
Definition: gas.h:125
StepCore::Particle::position
const Vector2d & position() const
Get position of the particle.
Definition: particle.h:117
StepCore::GasLJForceErrors::gasLJForce
GasLJForce * gasLJForce() const
Get owner as GasLJForce.
StepCore::ObjectErrors::owner
Item * owner() const
Get the owner of ObjectErrors.
Definition: world.h:58
StepCore::Gas::rectMass
double rectMass() const
Definition: gas.cc:280
STEPCORE_OBJECT
#define STEPCORE_OBJECT(_className)
Definition: object.h:49
StepCore::Particle::velocity
const Vector2d & velocity() const
Get velocity of the particle.
Definition: particle.h:122
StepCore::GasLJForce::rmin
double rmin() const
Get distance at which the interparticle force is zero.
Definition: gas.h:115
StepCore::Gas::createObjectErrors
ObjectErrors * createObjectErrors()
Definition: gas.h:208
StepCore::GasErrors::GasErrors
GasErrors(Item *owner=0)
Constructs GasErrors.
Definition: gas.h:150
StepCore::GasLJForce::createObjectErrors
ObjectErrors * createObjectErrors()
Definition: gas.h:129
StepCore::Gas::rectPressure
double rectPressure() const
Definition: gas.cc:498
StepCore::Gas::setMeasureRectCenter
void setMeasureRectCenter(const Vector2d &measureRectCenter)
Definition: gas.h:198
StepCore::Gas::randomGauss
double randomGauss(double mean=0, double deviation=1)
Definition: gas.cc:168
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:16:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

step/stepcore

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal