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

This function defines a archimedes screw 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 <Screw.h>

+ Inheritance diagram for Screw:

Public Member Functions

 Screw ()
 
 Screw (Vec3D Start, double L, double R, double N, double omega, double thickness)
 
virtual Screwcopy () 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 MaxR
 
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 archimedes screw 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 41 of file Screw.h.

Constructor & Destructor Documentation

Screw::Screw ( )
inline

Definition at line 45 of file Screw.h.

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

Referenced by copy().

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

Definition at line 59 of file Screw.h.

References L, MaxR, N, offset, omega, R, Start, and thickness.

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

Member Function Documentation

virtual Screw* Screw::copy ( ) const
inlinevirtual

Implements BaseWall.

Definition at line 73 of file Screw.h.

References Screw().

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

To find the contact point we have to minimize (with respect to r and 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

Differentiation with respect to r and solve for zero: 0=2*r-2*R*cos(alpha-2*Pi*(offset+N*q) r=R*cos(alpha-2*Pi*(offset+N*q))

Substitue back Distance^2=R^2+R^2*cos^2(alpha-2*Pi*(offset+N*q))-2*R^2*cos(alpha-2*Pi*(offset+N*q))*cos(alpha-2*Pi*(offset+N*q))+(dz-q*L)^2 Distance^2=R^2*sin^2(alpha-2*Pi*(offset+N*q))+(dz-q*L)^2

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

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

Definition at line 78 of file Screw.h.

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

79  {
80  double Rsqr=pow(P.get_Position().X-Start.X,2)+pow(P.get_Position().Y-Start.Y,2);
82  {
83  //std::cout<<"Particle is out of first bound checking"<<std::endl;
84  //std::cout<<"Rule 1: "<<Rsqr<<"<"<<pow(r+P.get_Radius()+thickness,2)<<std::endl;
85  //std::cout<<"Rule 2: "<<Start.Z-P.get_Radius()-thickness<<"<"<<P.get_Position().Z<<"<"<<L+Start.Z+P.get_Radius()+thickness<<std::endl;
86  return false;
87  }
88  double R=sqrt(Rsqr);
89  double alpha=atan2(P.get_Position().Y-Start.Y,P.get_Position().X-Start.X);
90  double dz=P.get_Position().Z-Start.Z;
91 
96 
100 
104 
108 
109  double q; //Current guess
110  double dd; //Derivative at current guess
111  double ddd; //Second derivative at current guess
112  double q0=dz/L; //Minimum of the parabolic part
113 
118 
119  double k=round(alpha/constants::pi-2.0*(offset+N*q0));
120  q=alpha/(2.0*constants::pi*N)-k/(2.0*N)-offset/N;
121 
122  //Now apply Newton's method
123  do
124  {
125  dd =-2.0*Rsqr*constants::pi*N*sin(2.0*alpha-4.0*constants::pi*(N*q+offset))-2.0*L*(dz-q*L);
126  ddd= 8.0*Rsqr*constants::sqr_pi*N*N*cos(2.0*alpha-4.0*constants::pi*(N*q+offset))+2.0*L*L;
127  q-=dd/ddd;
128  } while(fabs(dd/ddd)>1e-14);
129 
130  //Calculate r
131  double r=R*cos(2.0*constants::pi*(offset+N*q)-alpha);
132 
133  //Check if the location is actually on the screw:
134  //First posibility is that the radius is to large:
135  if(fabs(r)>MaxR) //Left boundary of the coil
136  {
137  r=mathsFunc::sign(r)*MaxR;
138  int steps=0;
139  //This case reduces to the coil problem
140  do
141  {
142  dd =-4.0*R*r*constants::pi *N *sin(alpha-2.0*constants::pi*(N*q+offset))-2.0*L*(dz-q*L);
143  ddd= 8.0*R*r*constants::sqr_pi*N*N*cos(alpha-2.0*constants::pi*(N*q+offset))+2.0*L*L;
144  q-=dd/ddd;
145  steps++;
146  } while(fabs(dd/ddd)>1e-14);
147  }
148  //Second possibility is that it occured before the start of after the end
149  if(q<0)
150  {
151  q=0;
152  r=R*cos(alpha-2.0*constants::pi*(offset+q*N));
153  if(fabs(r)>MaxR)
154  {
155  r=mathsFunc::sign(r)*MaxR;
156  }
157  }
158  else if(q>1)
159  {
160  q=1;
161  r=R*cos(alpha-2.0*constants::pi*(offset+q*N));
162  if(fabs(r)>MaxR)
163  {
164  r=mathsFunc::sign(r)*MaxR;
165  }
166  }
167 
168  distance=R*R*pow(sin(alpha-2*constants::pi*(offset+N*q)),2)+pow(dz-q*L,2);
169  //If distance is to large there is no contact
171  {
172  return false;
173  }
174 
175  Vec3D ContactPoint;
176  distance=sqrt(distance)-thickness;
177  ContactPoint.X=Start.X+r*cos(2.0*constants::pi*(offset+N*q));
178  ContactPoint.Y=Start.Y+r*sin(2.0*constants::pi*(offset+N*q));
179  ContactPoint.Z=Start.Z+q*L;
180  normal_return=ContactPoint-P.get_Position();
181  normal_return/=normal_return.GetLength();
182  return true;
183  }
Mdouble X
Definition: Vector.h:44
Vec3D Start
Definition: Screw.h:208
double L
Definition: Screw.h:209
int sign(T val)
This is a sign function, it returns -1 for negative numbers, 1 for positive numbers and 0 for 0...
Definition: ExtendedMath.h:75
double offset
Definition: Screw.h:209
const Mdouble pi
Definition: ExtendedMath.h:54
double thickness
Definition: Screw.h:209
Mdouble get_WallInteractionRadius() const
const Vec3D & get_Position() const
Mdouble Y
Definition: Vector.h:44
double N
Definition: Screw.h:209
Mdouble GetLength() const
Definition: Vector.h:248
double MaxR
Definition: Screw.h:209
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
Vec3D Screw::get_Velocity ( ) const
inlinevirtual

Todo{Implement this function correctly}.

Implements BaseWall.

Definition at line 205 of file Screw.h.

205 {return Vec3D(0.0,0.0,0.0);}
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:40
void Screw::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 186 of file Screw.h.

References offset, and omega.

187  {
188  offset+=omega*dt;
189  }
double offset
Definition: Screw.h:209
double omega
Definition: Screw.h:209
void Screw::print ( std::ostream &  os) const
inline

outputs wall

Definition at line 199 of file Screw.h.

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

200  {
201  os << "Screw start " << Start << " Length "<<L<<" Radius "<<MaxR<<" Revolutions "<<N<<" Omega "<<omega<<" Thickness "<<thickness<<" Offset "<<offset;
202  }
Vec3D Start
Definition: Screw.h:208
double L
Definition: Screw.h:209
double offset
Definition: Screw.h:209
double thickness
Definition: Screw.h:209
double N
Definition: Screw.h:209
double omega
Definition: Screw.h:209
double MaxR
Definition: Screw.h:209
void Screw::read ( std::istream &  is)
inline

reads wall

Definition at line 192 of file Screw.h.

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

193  {
194  std::string dummy;
195  is >> dummy >> Start >> dummy >> L >> dummy >> MaxR >> dummy >> N >> dummy >> omega >> dummy >> offset;
196  }
Vec3D Start
Definition: Screw.h:208
double L
Definition: Screw.h:209
double offset
Definition: Screw.h:209
double N
Definition: Screw.h:209
double omega
Definition: Screw.h:209
double MaxR
Definition: Screw.h:209

Member Data Documentation

double Screw::L
private

Definition at line 209 of file Screw.h.

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

double Screw::MaxR
private

Definition at line 209 of file Screw.h.

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

double Screw::N
private

Definition at line 209 of file Screw.h.

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

double Screw::offset
private

Definition at line 209 of file Screw.h.

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

double Screw::omega
private

Definition at line 209 of file Screw.h.

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

Vec3D Screw::Start
private

Definition at line 208 of file Screw.h.

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

double Screw::thickness
private

Definition at line 209 of file Screw.h.

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


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