MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Coil Class Reference

This function defines a coil in the z-direction from a (constant) starting point, a (constant) length L, a (constant) radius r, a (constant) number or revelations N and a (constant) rotation speed (rev/s) More...

#include <Coil.h>

+ Inheritance diagram for Coil:

Public Member Functions

 Coil ()
 
 Coil (Vec3D Start, double L, double r, double N, double omega, double thickness)
 
virtual Coilcopy () const
 
bool get_distance_and_normal (BaseParticle &P, Mdouble &distance, Vec3D &normal_return)
 
void move_time (Mdouble dt)
 Allows the wall to be moved to a new position (also orthogonal to the normal), and setting the velocity. More...
 
void read (std::istream &is)
 reads wall More...
 
void print (std::ostream &os) const
 outputs wall More...
 
Vec3D get_Velocity () const
 Todo{Implement this function correctly}. More...
 
- Public Member Functions inherited from BaseWall
 BaseWall ()
 
 BaseWall (const BaseWall &p)
 
virtual ~BaseWall ()
 
virtual void clear ()
 
virtual void move (Mdouble position_ UNUSED)
 Allows the wall to be moved to a new position. More...
 
virtual void move (Vec3D velocity_ UNUSED, Mdouble dt UNUSED)
 Allows the wall to be moved to a new position (also orthogonal to the normal), and setting the velocity. More...
 
virtual bool get_distance_and_normal (BaseParticle &P UNUSED, Mdouble &distance UNUSED, Vec3D &normal_return UNUSED)=0
 
void set_Velocity (Vec3D new_)
 access function for velocity More...
 
virtual void read (std::istream &is UNUSED)=0
 
virtual void print (std::ostream &os UNUSED) const =0
 
virtual void moveInHandler (int newPos)
 
int getIndSpecies () const
 
void setIndSpecies (const int _new)
 
const Vec3Dget_Force () const
 
const Vec3Dget_Torque () const
 
void set_Force (Vec3D _new)
 
void set_Torque (Vec3D _new)
 
void set_Index (int index)
 
void set_Id (int id)
 
void add_Force (Vec3D _new)
 
void add_Torque (Vec3D _new)
 

Private Attributes

Vec3D Start
 
double L
 
double r
 
double N
 
double omega
 
double offset
 
double thickness
 

Additional Inherited Members

- Public Attributes inherited from BaseWall
int indSpecies
 
- Protected Attributes inherited from BaseWall
Vec3D velocity
 velocity of the wall (used to calculate the relative velocity in the force calculation) More...
 

Detailed Description

This function defines a coil in the z-direction from a (constant) starting point, a (constant) length L, a (constant) radius r, a (constant) number or revelations N and a (constant) rotation speed (rev/s)

q is a new coordinate going from 0 to 1 and t is the time x=xs+r*cos(2*pi*(offset+N*q)) y=ys+r*sin(2*pi*(offset+N*q)) z=zs+q*L

Definition at line 40 of file Coil.h.

Constructor & Destructor Documentation

Coil::Coil ( )
inline

Definition at line 44 of file Coil.h.

References L, N, offset, omega, r, Vec3D::set_zero(), Start, and thickness.

Referenced by copy().

44  : BaseWall()
45  {
46  Start.set_zero();
47  L=1;
48  r=1;
49  N=1;
50  omega=1;
51  offset=0;
52  thickness=0;
53  #ifdef CONSTUCTOR_OUTPUT
54  std::cerr << "Coil() finished" << std::endl;
55  #endif
56  }
Vec3D Start
Definition: Coil.h:173
double offset
Definition: Coil.h:174
double L
Definition: Coil.h:174
double r
Definition: Coil.h:174
BaseWall()
Definition: BaseWall.h:38
double thickness
Definition: Coil.h:174
void set_zero()
Definition: Vector.h:55
double N
Definition: Coil.h:174
double omega
Definition: Coil.h:174
Coil::Coil ( Vec3D  Start,
double  L,
double  r,
double  N,
double  omega,
double  thickness 
)
inline

Definition at line 58 of file Coil.h.

References L, N, offset, omega, r, Start, and thickness.

58  : BaseWall()
59  {
60  this->Start=Start;
61  this->L=L;
62  this->r=r;
63  this->N=N;
64  this->omega=omega;
65  this->thickness=thickness;
66  this->offset=0.0;
67  #ifdef CONSTUCTOR_OUTPUT
68  std::cerr << "Coil() finished" << std::endl;
69  #endif
70  }
Vec3D Start
Definition: Coil.h:173
double offset
Definition: Coil.h:174
double L
Definition: Coil.h:174
double r
Definition: Coil.h:174
BaseWall()
Definition: BaseWall.h:38
double thickness
Definition: Coil.h:174
double N
Definition: Coil.h:174
double omega
Definition: Coil.h:174

Member Function Documentation

virtual Coil* Coil::copy ( ) const
inlinevirtual

Implements BaseWall.

Definition at line 72 of file Coil.h.

References Coil().

73  {
74  return new Coil(*this);
75  }
Coil()
Definition: Coil.h:44
bool Coil::get_distance_and_normal ( BaseParticle P,
Mdouble distance,
Vec3D normal_return 
)
inline

To find the contact point we have to minimize (with respect to q) Distance^2=(x-x0-r*cos(2*Pi*(offset+N*q)))^2+(y-y0-r*sin(2*Pi*(offset+N*q)))^2+(z-z0-q*L)^2 Using polar coordinated (i.e. x-x0=R*cos(alpha), y-y0=R*sin(alpha) and dz=z-z0) Distance^2=R^2+r^2-2*R*r*cos(alpha-2*Pi*(offset+N*q))+(dz-q*L)^2

So we have to minimize: Distance^2=R^2+r^2-2*R*r*cos(alpha-2*Pi*(offset+N*q))+(dz-q*L)^2 For this we use the Euler algoritm

The initial guess will be in the maximum of the cos closest to the minimum of the parabolic part Minima of the cos are at alpha-2*Pi*(offset+N*q)=2*k*Pi (k=integer) q=alpha/(2*Pi*N)-k/N-offset/N (k=integer)

Definition at line 77 of file Coil.h.

References BaseParticle::get_Position(), BaseParticle::get_WallInteractionRadius(), Vec3D::GetLength(), L, N, offset, constants::pi, R, r, constants::sqr_pi, Start, thickness, Vec3D::X, Vec3D::Y, and Vec3D::Z.

78  {
79  double Rsqr=pow(P.get_Position().X-Start.X,2)+pow(P.get_Position().Y-Start.Y,2);
81  {
82  //std::cout<<"Particle is out of first bound checking"<<std::endl;
83  //std::cout<<"Rule 1: "<<pow(r-P.get_Radius()-thickness,2)<<"<"<<Rsqr<<"<"<<pow(r+P.get_Radius()+thickness,2)<<std::endl;
84  //std::cout<<"Rule 2: "<<Start.Z-P.get_Radius()-thickness<<"<"<<P.get_Position().Z<<"<"<<L+Start.Z+P.get_Radius()+thickness<<std::endl;
85  return false;
86  }
87  double R=sqrt(Rsqr);
88  double alpha=atan2(P.get_Position().Y-Start.Y,P.get_Position().X-Start.X);
89  double dz=P.get_Position().Z-Start.Z;
90 
95 
99 
100  double q; //Current guess
101  double dd; //Derivative at current guess
102  double ddd; //Second derivative at current guess
103  double q0=dz/L; //Minimum of the parabolic part
104 
109 
110  double k=round(alpha/2.0/constants::pi-(offset+N*q0));
111  q=alpha/(2*constants::pi*N)-k/N-offset/N;
112 
113  //Now apply Newton's method
114  do
115  {
116  dd =-4.0*R*r*constants::pi *N *sin(alpha-2.0*constants::pi*(N*q+offset))-2.0*L*(dz-q*L);
117  ddd= 8.0*R*r*constants::sqr_pi*N*N*cos(alpha-2.0*constants::pi*(N*q+offset))+2.0*L*L;
118  q-=dd/ddd;
119  } while(fabs(dd/ddd)>1e-14);
120 
121 
122  //Check if the location is actually on the coil, otherwise a point collision with the end of the coil calculated
123  if(q<0) //Left boundary of the coil
124  {
125  q=0;
126  }
127  else if(q>1) //right boundary of the coil
128  {
129  q=1;
130  }
131 
132  distance=R*R+r*r-2*R*r*cos(alpha-2*constants::pi*(offset+N*q))+pow(dz-q*L,2);
133  //If distance is to large there is no contact
135  {
136  //std::cout<<"Particle is out of second bound checking, distance^2="<<distance<<" max="<<(P.get_Radius()+thickness)*(P.get_Radius()+thickness)<<std::endl;
137  return false;
138  }
139 
140  Vec3D ContactPoint;
141  distance=sqrt(distance)-thickness;
142  ContactPoint.X=Start.X+r*cos(2.0*constants::pi*(offset+N*q));
143  ContactPoint.Y=Start.Y+r*sin(2.0*constants::pi*(offset+N*q));
144  ContactPoint.Z=Start.Z+q*L;
145  normal_return=ContactPoint-P.get_Position();
146  normal_return/=normal_return.GetLength();
147  return true;
148  }
Vec3D Start
Definition: Coil.h:173
Mdouble X
Definition: Vector.h:44
double offset
Definition: Coil.h:174
double L
Definition: Coil.h:174
double r
Definition: Coil.h:174
const Mdouble pi
Definition: ExtendedMath.h:54
Mdouble get_WallInteractionRadius() const
double thickness
Definition: Coil.h:174
const Vec3D & get_Position() const
Mdouble Y
Definition: Vector.h:44
Mdouble GetLength() const
Definition: Vector.h:248
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:40
Mdouble Z
Definition: Vector.h:44
const Mdouble sqr_pi
Definition: ExtendedMath.h:56
double N
Definition: Coil.h:174
Vec3D Coil::get_Velocity ( ) const
inlinevirtual

Todo{Implement this function correctly}.

Implements BaseWall.

Definition at line 170 of file Coil.h.

170 {return Vec3D(0.0,0.0,0.0);}
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:40
void Coil::move_time ( Mdouble dt  )
inlinevirtual

Allows the wall to be moved to a new position (also orthogonal to the normal), and setting the velocity.

Reimplemented from BaseWall.

Definition at line 151 of file Coil.h.

References offset, and omega.

152  {
153  offset+=omega*dt;
154  }
double offset
Definition: Coil.h:174
double omega
Definition: Coil.h:174
void Coil::print ( std::ostream &  os) const
inline

outputs wall

Definition at line 164 of file Coil.h.

References L, N, offset, omega, r, Start, and thickness.

165  {
166  os << "Coil Start " << Start << " Length "<<L<<" Radius "<<r<<" Revolutions "<<N<<" Omega "<<omega<<" Thickness "<<thickness<<" Offset "<<offset;
167  }
Vec3D Start
Definition: Coil.h:173
double offset
Definition: Coil.h:174
double L
Definition: Coil.h:174
double r
Definition: Coil.h:174
double thickness
Definition: Coil.h:174
double N
Definition: Coil.h:174
double omega
Definition: Coil.h:174
void Coil::read ( std::istream &  is)
inline

reads wall

Definition at line 157 of file Coil.h.

References L, N, offset, omega, r, and Start.

158  {
159  std::string dummy;
160  is >> dummy >> Start >> dummy >> L >> dummy >> r >> dummy >> N >> dummy >> omega >> dummy >> offset;
161  }
Vec3D Start
Definition: Coil.h:173
double offset
Definition: Coil.h:174
double L
Definition: Coil.h:174
double r
Definition: Coil.h:174
double N
Definition: Coil.h:174
double omega
Definition: Coil.h:174

Member Data Documentation

double Coil::L
private

Definition at line 174 of file Coil.h.

Referenced by Coil(), get_distance_and_normal(), print(), and read().

double Coil::N
private

Definition at line 174 of file Coil.h.

Referenced by Coil(), get_distance_and_normal(), print(), and read().

double Coil::offset
private

Definition at line 174 of file Coil.h.

Referenced by Coil(), get_distance_and_normal(), move_time(), print(), and read().

double Coil::omega
private

Definition at line 174 of file Coil.h.

Referenced by Coil(), move_time(), print(), and read().

double Coil::r
private

Definition at line 174 of file Coil.h.

Referenced by Coil(), get_distance_and_normal(), print(), and read().

Vec3D Coil::Start
private

Definition at line 173 of file Coil.h.

Referenced by Coil(), get_distance_and_normal(), print(), and read().

double Coil::thickness
private

Definition at line 174 of file Coil.h.

Referenced by Coil(), get_distance_and_normal(), and print().


The documentation for this class was generated from the following file: