<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.iac.isu.edu/index.php?action=history&amp;feed=atom&amp;title=RDYNLAB_Code</id>
	<title>RDYNLAB Code - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.iac.isu.edu/index.php?action=history&amp;feed=atom&amp;title=RDYNLAB_Code"/>
	<link rel="alternate" type="text/html" href="https://wiki.iac.isu.edu/index.php?title=RDYNLAB_Code&amp;action=history"/>
	<updated>2026-05-09T18:21:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>https://wiki.iac.isu.edu/index.php?title=RDYNLAB_Code&amp;diff=44410&amp;oldid=prev</id>
		<title>Oborn at 18:06, 18 June 2009</title>
		<link rel="alternate" type="text/html" href="https://wiki.iac.isu.edu/index.php?title=RDYNLAB_Code&amp;diff=44410&amp;oldid=prev"/>
		<updated>2009-06-18T18:06:22Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.iac.isu.edu/index.php?title=RDYNLAB_Code&amp;amp;diff=44410&amp;amp;oldid=44409&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Oborn</name></author>
	</entry>
	<entry>
		<id>https://wiki.iac.isu.edu/index.php?title=RDYNLAB_Code&amp;diff=44409&amp;oldid=prev</id>
		<title>Oborn: New page: The following files constitute the source code for RDYNLAB. They can be compiled with any source code intended to use the library functions or (preferably) compiled as a shared object ...</title>
		<link rel="alternate" type="text/html" href="https://wiki.iac.isu.edu/index.php?title=RDYNLAB_Code&amp;diff=44409&amp;oldid=prev"/>
		<updated>2009-06-18T18:04:32Z</updated>

		<summary type="html">&lt;p&gt;New page: The following files constitute the source code for &lt;a href=&quot;/./index.php?title=RDYNLAB&quot; title=&quot;RDYNLAB&quot;&gt;RDYNLAB&lt;/a&gt;. They can be compiled with any source code intended to use the library functions or (preferably) compiled as a shared object ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The following files constitute the source code for [[RDYNLAB]]. They can be compiled with any source code intended to use the library functions or (preferably) compiled as a shared object library using GNU autoconf, automake, and libtool. Compiling a shared object library is beyond the scope of this document. The package, with the appropriate configure scripts and makefiles, can be obtained by contacting the author (kelleyk@byui.edu).&lt;br /&gt;
&lt;br /&gt;
It should be noted that the library is written in C++, and will probably only compile or work properly with other C++ codes.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''***rdynlab.h***'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* RDYNLAB: Relativistic particle DYNamics in the LAB frame. */&lt;br /&gt;
&lt;br /&gt;
#ifndef _RDYNLAB_H_&lt;br /&gt;
#define _RDYNLAB_H_&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
/* Some global control parameters */&lt;br /&gt;
&lt;br /&gt;
#define RDL_TINY 1.e+00 /* Required numerical accuracy */&lt;br /&gt;
#define RDL_TMAX 1.e+18 /* Maximum time we will ever be allowed to run to.&lt;br /&gt;
                         * This number can be rediculously large, since the&lt;br /&gt;
		         * stopping time will normally be provided by the&lt;br /&gt;
			 * user. */&lt;br /&gt;
&lt;br /&gt;
/* A few constants that we will need */&lt;br /&gt;
&lt;br /&gt;
#define RDL_CLIGHT 2.99792458E8 /* Speed of light in vacuum */&lt;br /&gt;
&lt;br /&gt;
#define RDL_MU0 1.25663706144E-6 /* Permeability of free space, needed for power&lt;br /&gt;
                                  * loss of charged particles */&lt;br /&gt;
&lt;br /&gt;
/*****************************  Vector Class **********************************/&lt;br /&gt;
&lt;br /&gt;
class RDL_Vector&lt;br /&gt;
{&lt;br /&gt;
  public:&lt;br /&gt;
    double x,y,z; /* The three components of a vector */&lt;br /&gt;
&lt;br /&gt;
    /* Construction and destruction operators */&lt;br /&gt;
&lt;br /&gt;
    RDL_Vector() {};&lt;br /&gt;
   ~RDL_Vector() {};&lt;br /&gt;
    RDL_Vector(double,double,double);&lt;br /&gt;
&lt;br /&gt;
    /* Operators */&lt;br /&gt;
&lt;br /&gt;
    RDL_Vector operator+(const RDL_Vector&amp;amp;); /* Add vectors */&lt;br /&gt;
    RDL_Vector operator+(void);              /* &amp;quot;Positive&amp;quot; of a vector */&lt;br /&gt;
    RDL_Vector operator-(const RDL_Vector&amp;amp;); /* Subtract vectors */&lt;br /&gt;
    RDL_Vector operator-(void);              /* &amp;quot;Negative&amp;quot; of a vector */&lt;br /&gt;
    RDL_Vector operator*(double);            /* Multiply vector by scalar */&lt;br /&gt;
    double operator*(const RDL_Vector&amp;amp;);     /* Vector dot product */&lt;br /&gt;
    RDL_Vector operator/(double);            /* Divide vector by scalar */&lt;br /&gt;
    RDL_Vector operator^(const RDL_Vector&amp;amp;); /* Vector cross product */&lt;br /&gt;
    bool operator==(const RDL_Vector&amp;amp;);      /* Are vectors the same? */&lt;br /&gt;
    &lt;br /&gt;
    /* Friends to this class */&lt;br /&gt;
&lt;br /&gt;
    friend ostream &amp;amp;operator&amp;lt;&amp;lt;(ostream &amp;amp;out,const RDL_Vector &amp;amp;V);&lt;br /&gt;
    friend RDL_Vector operator*(double a, const RDL_Vector &amp;amp;V);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/* Define &amp;lt;&amp;lt; operator for vectors */&lt;br /&gt;
&lt;br /&gt;
ostream &amp;amp;operator&amp;lt;&amp;lt;(ostream &amp;amp;out, const RDL_Vector &amp;amp;V);&lt;br /&gt;
&lt;br /&gt;
/* Allows us to do scalar times vector */&lt;br /&gt;
&lt;br /&gt;
RDL_Vector operator*(double a, const RDL_Vector &amp;amp;V);&lt;br /&gt;
&lt;br /&gt;
/* These return the length of a vector and a unit vector */&lt;br /&gt;
&lt;br /&gt;
double length(const RDL_Vector &amp;amp;V);&lt;br /&gt;
RDL_Vector unit(const RDL_Vector &amp;amp;V);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*****************************  Particle Class ********************************/&lt;br /&gt;
&lt;br /&gt;
class RDL_Particle&lt;br /&gt;
{&lt;br /&gt;
  public:&lt;br /&gt;
    double q;     /* Charge, in Coulombs */&lt;br /&gt;
    double m;     /* Mass, in kg */&lt;br /&gt;
    RDL_Vector x;     /* Position, in meters */&lt;br /&gt;
    RDL_Vector v;     /* Velocity, in m/s */&lt;br /&gt;
&lt;br /&gt;
    /* Construction and Destruction operators */&lt;br /&gt;
&lt;br /&gt;
    RDL_Particle() {};&lt;br /&gt;
   ~RDL_Particle() {};&lt;br /&gt;
    RDL_Particle(double, double, const RDL_Vector&amp;amp;, const RDL_Vector&amp;amp;); &lt;br /&gt;
      /* Init with q,m,x,v */&lt;br /&gt;
&lt;br /&gt;
    /* We need to define the = operator */&lt;br /&gt;
&lt;br /&gt;
    RDL_Particle operator=(const RDL_Particle&amp;amp;);&lt;br /&gt;
&lt;br /&gt;
    /* Allow the &amp;lt;&amp;lt; operator access... */&lt;br /&gt;
&lt;br /&gt;
    friend ostream &amp;amp;operator&amp;lt;&amp;lt;(ostream &amp;amp;out, const RDL_Particle &amp;amp;p);&lt;br /&gt;
&lt;br /&gt;
    /* Return particle properties */&lt;br /&gt;
&lt;br /&gt;
    double gamma(void);          /* Returns relativistic factor gamma */&lt;br /&gt;
    double energy(void);         /* Returns total energy */&lt;br /&gt;
    double kinetic_energy(void); /* Returns kinetic energy */&lt;br /&gt;
    double rest_energy(void);    /* Returns rest energy */&lt;br /&gt;
    RDL_Vector momentum(void);       /* Returns momentum vector */&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/* Overload &amp;lt;&amp;lt; operator for particles */&lt;br /&gt;
&lt;br /&gt;
ostream &amp;amp;operator&amp;lt;&amp;lt;(ostream &amp;amp;out, const RDL_Particle &amp;amp;p);&lt;br /&gt;
&lt;br /&gt;
/******************* Struct for passing information to GSL ********************/&lt;br /&gt;
&lt;br /&gt;
struct RDL_solver_parameters&lt;br /&gt;
{&lt;br /&gt;
  RDL_Particle p;                                 /* The particle */&lt;br /&gt;
  double t;                                   /* The time */&lt;br /&gt;
  RDL_Vector (*f)(const RDL_Particle&amp;amp;,double);  /* Function returning force */&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/******************** Declaration of main solver routine **********************/&lt;br /&gt;
&lt;br /&gt;
/* This is the main solver routine. Input parameters are the particle,&lt;br /&gt;
 * a function that returns the force, the initial time, the initial time step, &lt;br /&gt;
 * a function that determines if the simulation should stop, and an ostream for&lt;br /&gt;
 * writing output.&lt;br /&gt;
 *&lt;br /&gt;
 * The force function takes arguments of a particle (which will include position&lt;br /&gt;
 * and velocity) and time. The stopping condition function takes arguments of a&lt;br /&gt;
 * particle (which has the particle's position and velocity), the time, and the&lt;br /&gt;
 * number of iterations the solver has completed. */&lt;br /&gt;
&lt;br /&gt;
int RDL_solver(RDL_Particle&amp;amp;, &lt;br /&gt;
               RDL_Vector (*)(const RDL_Particle&amp;amp;,double), &lt;br /&gt;
	       double, double, &lt;br /&gt;
	       int (*)(const RDL_Particle&amp;amp;,double,int),&lt;br /&gt;
	       ostream&amp;amp;);&lt;br /&gt;
&lt;br /&gt;
/* This function is required by the solver routine, and will probably never&lt;br /&gt;
 * need to be called from user space. */&lt;br /&gt;
&lt;br /&gt;
int RDL_solver_func(double t,&lt;br /&gt;
                    const double y[],&lt;br /&gt;
	  	    double f[], &lt;br /&gt;
	            void *params);&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''***RDLvector.cpp***'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* RDLvector.c: 3-D vectors and functions */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;rdynlab.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
/* Constructor */&lt;br /&gt;
&lt;br /&gt;
RDL_Vector::RDL_Vector (double xin, double yin, double zin) &lt;br /&gt;
{&lt;br /&gt;
  x = xin;&lt;br /&gt;
  y = yin;&lt;br /&gt;
  z = zin;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Operators */&lt;br /&gt;
&lt;br /&gt;
RDL_Vector RDL_Vector::operator+(const RDL_Vector &amp;amp;param) &lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp;&lt;br /&gt;
  temp.x = x + param.x;&lt;br /&gt;
  temp.y = y + param.y;&lt;br /&gt;
  temp.z = z + param.z;&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
RDL_Vector RDL_Vector::operator+(void)&lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp;&lt;br /&gt;
  temp.x = x;&lt;br /&gt;
  temp.y = y;&lt;br /&gt;
  temp.z = z;&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
RDL_Vector RDL_Vector::operator-(const RDL_Vector &amp;amp;param)&lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp;&lt;br /&gt;
  temp.x = x - param.x;&lt;br /&gt;
  temp.y = y - param.y;&lt;br /&gt;
  temp.z = z - param.z;&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
RDL_Vector RDL_Vector::operator-(void)&lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp;&lt;br /&gt;
  temp.x = -x;&lt;br /&gt;
  temp.y = -y;&lt;br /&gt;
  temp.z = -z;&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
RDL_Vector RDL_Vector::operator*(double a)&lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp;&lt;br /&gt;
  temp.x = x*a;&lt;br /&gt;
  temp.y = y*a;&lt;br /&gt;
  temp.z = z*a;&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
double RDL_Vector::operator*(const RDL_Vector &amp;amp;param)&lt;br /&gt;
{&lt;br /&gt;
  double temp;&lt;br /&gt;
  temp = (x * param.x) + (y * param.y) + (z * param.z);&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
RDL_Vector RDL_Vector::operator/(double a)&lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp;&lt;br /&gt;
  temp.x = x/a;&lt;br /&gt;
  temp.y = y/a;&lt;br /&gt;
  temp.z = z/a;&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
RDL_Vector RDL_Vector::operator^(const RDL_Vector &amp;amp;param)&lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp;&lt;br /&gt;
  temp.x = (y * param.z) - (z * param.y);&lt;br /&gt;
  temp.y = (z * param.x) - (x * param.z);&lt;br /&gt;
  temp.z = (x * param.y) - (y * param.x);&lt;br /&gt;
  return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool RDL_Vector::operator==(const RDL_Vector &amp;amp;param)&lt;br /&gt;
{&lt;br /&gt;
  if(param.x==x &amp;amp;&amp;amp; param.y==y &amp;amp;&amp;amp; param.z==z) return true;&lt;br /&gt;
  else return false;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* &amp;lt;&amp;lt; operator */&lt;br /&gt;
&lt;br /&gt;
ostream &amp;amp;operator&amp;lt;&amp;lt;(ostream &amp;amp;out, const RDL_Vector &amp;amp;V)&lt;br /&gt;
{&lt;br /&gt;
  out &amp;lt;&amp;lt; &amp;quot;&amp;lt;&amp;quot; &amp;lt;&amp;lt; V.x &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; V.y &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; V.z &amp;lt;&amp;lt; &amp;quot;&amp;gt;&amp;quot;;&lt;br /&gt;
  return out;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* This one allows double*RDL_Vector */&lt;br /&gt;
&lt;br /&gt;
RDL_Vector operator*(double a, const RDL_Vector &amp;amp;V)&lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp;&lt;br /&gt;
  temp.x = V.x*a;&lt;br /&gt;
  temp.y = V.y*a;&lt;br /&gt;
  temp.z = V.z*a;&lt;br /&gt;
  return (temp);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Return the length of a vector, unit vector */&lt;br /&gt;
&lt;br /&gt;
double length(const RDL_Vector &amp;amp;V)&lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp=V;&lt;br /&gt;
  return sqrt(temp*temp);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
RDL_Vector unit(const RDL_Vector &amp;amp;V)&lt;br /&gt;
{&lt;br /&gt;
  RDL_Vector temp=V;&lt;br /&gt;
  double s=length(temp);&lt;br /&gt;
  /* Return zero if the length is zero */&lt;br /&gt;
  if(s&amp;gt;0) return temp/s;&lt;br /&gt;
  else return temp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''***RDLparticle.cpp***'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''***RDLsolver.cpp***'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''***RDLsolver_func.cpp***'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Oborn</name></author>
	</entry>
</feed>