00001
00004 namespace Species {
00005 extern int nspecies;
00006 class Specie {
00007 char id[WORDLENGTH];
00008 REAL mass,size,
00009 cp,
00010
00011 inertia[DIM];
00012 public:
00013 Specie() {
00014 id[0]='\0';
00015 mass=size=cp=0.0;
00016 for(int i=0;i<DIM;i++) inertia[i]=0.0;
00017 }
00018
00019
00020 inline void Cp(REAL c) {cp=c;}
00021 inline REAL Cp() {return cp;}
00022 inline char* Id() {return id;}
00023 inline void Mass(REAL m) { mass=m; }
00024 inline REAL Mass() { return mass; }
00025 inline REAL Size() { return size; }
00026 inline void Size(REAL s) { size=s; }
00027 };
00029 struct Gas {
00030 REAL density;
00031 Specie *specie;
00032 Gas(Specie *s) {specie=s;}
00033 };
00035 struct Reaction {
00037 struct Outcome {
00038 int product[2];
00039 REAL activationEnergy,probability,enthalpy,
00040 time;
00041
00042
00043 Outcome *next;
00044 Outcome() {
00045 for(int j=0;j<2;j++) product[j]=VOIDSPECIE;
00046 probability=enthalpy=time=0.0;
00047 next=NULL;
00048 }
00049 Outcome(
00050 int ip0,
00051 int ip1,
00052 REAL a,
00053 REAL p,
00054 REAL h
00055 ) {
00056 if(ip0<0||ip0>nspecies) {
00057 cout<<"ERROR: Invalid first product specie index "<<ip0<<" of maximum "<<nspecies<<endl;
00058 exit(1);
00059 }
00060 product[0]=ip0;
00061 if(ip1<0||ip1>nspecies) {
00062 cout<<"ERROR: Invalid second product specie index "<<ip1<<" of maximum "<<nspecies<<endl;
00063 exit(1);
00064 }
00065 product[1]=ip1;
00066 activationEnergy=a;
00067 probability=p;
00068 enthalpy=h;
00069 time=0.0;
00070 next=NULL;
00071 }
00072 #ifdef ADSORPTION
00073 Outcome(
00074 int ip0,
00075 int ip1,
00076 REAL a,
00077 REAL p,
00078 REAL h,
00079 REAL t
00080 ) {
00081 if(ip0<0||ip0>nspecies) {
00082 cout<<"ERROR: Invalid first product specie index "<<ip0<<" of maximum "<<nspecies<<endl;
00083 exit(1);
00084 }
00085 product[0]=ip0;
00086 if(ip1<0||ip1>nspecies) {
00087 cout<<"ERROR: Invalid second product specie index "<<ip1<<" of maximum "<<nspecies<<endl;
00088 exit(1);
00089 }
00090 product[1]=ip1;
00091 activationEnergy=a;
00092 probability=p;
00093 enthalpy=h;
00094 time=t;
00095 next=NULL;
00096 }
00097 #endif
00098 void Products(int ip0, int ip1) {
00099 if(ip0<0||ip0>=nspecies) {
00100 cout<<"Product index "<<ip0<<" outside of species index\n";
00101 exit(1);
00102 }
00103 product[0]=ip0;
00104 if(ip1<0||ip1>=nspecies) {
00105 cout<<"Product index "<<ip1<<" outside of species index\n";
00106 exit(1);
00107 }
00108 product[1]=ip1;
00109 }
00110 int Product(int i) {
00111 if(i<0||i>1) {
00112 cout<<"ERROR: product index "<<i<<" outside of bounds\n";
00113 exit(1);
00114 }
00115 return product[i];
00116 }
00117 inline void Time(REAL t) {time=t;}
00118 inline REAL Time() {return time;}
00119 inline void ActivationEnergy(REAL a) { activationEnergy=a; }
00120 inline REAL ActivationEnergy() { return activationEnergy; }
00121 inline void Probability(REAL r) { probability=r; }
00122 inline REAL Probability() { return probability; }
00123 inline void Enthalpy(REAL h) { enthalpy=h; }
00124 inline REAL Enthalpy() { return enthalpy; }
00125 } *outcomes,*current;
00126 Reaction() {current=outcomes=NULL;}
00127 ~Reaction() {
00128 Erase(outcomes);
00129 outcomes=NULL;
00130 }
00131 void Erase(Outcome *outcome) {
00132 if(outcome->next!=NULL) Erase(outcome->next);
00133 delete outcome;
00134 }
00135 void Add(int ip0, int ip1, REAL a, REAL p, REAL h) {
00137 if(outcomes==NULL) {
00138 outcomes=new Outcome(ip0,ip1,a,p,h);
00139 return;
00140 }
00141 Outcome *outcome=outcomes;
00142 for(;outcome->next!=NULL;outcome=outcome->next);
00143 outcome->next=new Outcome(ip0,ip1,a,p,h);
00144 }
00145 #ifdef ADSORPTION
00146 void Add(int ip0, int ip1, REAL a, REAL p, REAL h, REAL t) {
00148 if(outcomes==NULL) {
00149 outcomes=new Outcome(ip0,ip1,a,p,h,t);
00150 return;
00151 }
00152 Outcome *outcome=outcomes;
00153 for(;outcome->next!=NULL;outcome=outcome->next);
00154 outcome->next=new Outcome(ip0,ip1,a,p,h,t);
00155 }
00156 #endif
00157 Outcome *First() { current=outcomes; return current; }
00158 Outcome *Next() {
00159 current=current->next;
00160 if(current!=NULL) return current;
00161 current=outcomes; return NULL;
00162 }
00163 };
00164 enum Interaction {
00165 missed=0,
00166 collided,
00167 reacted,
00168 annihalated
00169 };
00170 extern Specie *species;
00171 extern Reaction *reactions;
00172 }
00173