Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

lattice.h

Go to the documentation of this file.
00001 #ifndef _LATTICE_H_
00002 #define _LATTICE_H_
00003 
00004 #include <TROOT.h>
00005 #include <TSystem.h>
00006 #include <TThread.h>
00007 #include <TCanvas.h>
00008 #include <TMarker.h>
00009 #include <TText.h>
00010 #include <TObjArray.h>
00011 #include <stdlib.h>
00012 #include <time.h>
00013 
00014 class Layer;
00015 class Lattice;
00016 
00017 #include "gui.h"
00018 #include "configuration.h"
00019 #include "formula.h"
00020 
00021 class MainFrame;
00022 class Atom;
00023 
00024 
00026 class Layer : public TCanvas
00027 {
00028     public:
00029         Layer();
00031         Layer(MainFrame*, Configuration*, const char* name, Int_t ww, Int_t wh, Int_t winid);
00032         ~Layer();
00033         
00035         Lattice* GetLattice() { return pLattice; }      
00036         MainFrame* GetMainFrame() { return pMainFrame; }
00037         Double_t GetCurEnergy() { return curEnergy; }
00038         Double_t GetBoltzConst() { return pConfig->GetBoltzConst(); }
00039         Double_t GetTemp() { return pConfig->GetTemp(); }
00040         Bool_t RunSimulation() { return runSimulation; }
00042         void ExecuteEvent(Int_t event, Int_t px, Int_t py);
00044         void SetLattice(Int_t, Int_t, Int_t, Double_t);
00046         void SetFormula(TEFormula *f) { pEFormula = f; }
00048         void SetCurEnergy(Double_t e) { curEnergy = e; }
00050         void SetIntLimit(Double_t l) { intLimit = l; }
00052         void StopSimulation() { runSimulation = kFALSE; }
00053 //****** These functions are not thread-safe, be sure to lock your code when using them *******
00055         Bool_t MoveDefect(Double_t&);
00057         void UndoMoveDefect();
00059         Double_t CompEnergy();
00061         Double_t CompPartEnergy(Atom*);
00063 //****** See MonteCarlo() for code-locking *****************************************************
00064         static void MonteCarlo(void*);
00065         Int_t MonteCarloStart(MainFrame*);
00066         Int_t MonteCarloStop();
00067         
00068         Configuration* GetConfig() { return pConfig; }
00069         
00070     private:
00071         Int_t oldAtomIndex;
00072         Int_t newAtomIndex;
00073         Bool_t runSimulation;
00074         Double_t intLimit;      
00075         Double_t curEnergy;     
00076         Lattice *pLattice;      
00077         TEFormula *pEFormula;   
00078         TText *pInfoText;       
00079         MainFrame *pMainFrame;  
00080         Configuration *pConfig; 
00081         TThread *mcThread;      
00082 };
00083 
00084 enum EAtomPosition {
00085     kAtomTop = BIT(0),
00086     kAtomLeft = BIT(1),
00087     kAtomBottom = BIT(2),
00088     kAtomRight = BIT(3),
00089     kAtomCenter = BIT(4)
00090 };
00091 
00092 
00094 class Atom : public TMarker
00095 {
00096     public:
00097         friend class Layer;
00098         friend class Lattice;
00099     
00100         Atom(Double_t x, Double_t y, Int_t, Lattice*);
00101         virtual ~Atom();
00102         
00104         void ExecuteEvent(Int_t event, Int_t px, Int_t py);
00106         void InsertDefect(); // *MENU*
00107         void RemoveDefect(); // *MENU*
00108         void CompPartEnergy(); // *MENU*
00109         void SetLink(Bool_t fl) { bLink = fl; }
00110             
00111         Bool_t IsDefect() { return bDefect; }
00112         
00113     private:
00114         Bool_t bDefect;         
00115         Bool_t bBorderAtom;     
00116         Bool_t bCornerAtom;     
00117         Bool_t bLink;           
00118         Int_t index;            
00119         UChar_t pos;            
00120         UChar_t type;           
00121         Atom *linkedAtom;       
00122         Atom *linkedAtoms[3];   
00123         Lattice *pLattice;      
00125     /* That is needed for additional class information, so
00126        ROOT can parse the dictionary file for context menu
00127        entries, like the InsertDefect() function */
00128     ClassDef(Atom,0)
00129 };
00130 
00131 enum ELatticeType {
00132     kLSquare, kLHexagonal
00133 };
00134 
00136 class Lattice
00137 {
00138     public:
00139         friend class Atom;
00140     
00141         Lattice();
00142         Lattice(Layer* pLayer, Int_t Nx, Int_t Ny, Double_t c);
00143         virtual ~Lattice();
00144         
00146         virtual void CreateLattice() = 0;
00148         virtual Atom* GetAtomNeighbor(Atom*) = 0;
00149         
00150         Int_t GetAtomIndex(Atom* atom) { return atom->index; }
00151         UChar_t GetAtomPos(Atom* atom) { return atom->pos; }
00152         UChar_t GetAtomType(Atom* atom) { return atom->type; }
00153         Double_t GetCellSize() { return c; }
00154         Double_t GetWidth() { return pLayer->GetX2(); }
00155         Double_t GetHeight() { return pLayer->GetY2(); }
00157         void SetBorderMode(Atom*, Atom*, UChar_t);
00158         void SetCornerMode(Atom*, Atom*, Atom*, Atom*, UChar_t);
00159         void SetAtomType(Atom* atom, UChar_t type) { atom->type = type; }
00160         void SetInfo(Bool_t fl) { bInfo = fl; }
00161     
00163         virtual void ShowLattice();
00165         TObjArray* GetDefects() { return defects; }
00166         Atom** GetAtoms() { return atoms; }
00167         Int_t GetNAtoms() { return N; }
00168         Int_t GetNUniqueAtoms() { return Nu; }
00169         Int_t GetNUniqueDefects() { return defArrayCount; }
00171         void SetAtomStyle(Style_t, Size_t, Color_t);
00173         void SetDefectStyle(Style_t, Size_t, Color_t);
00175         void RndInsertDefect();
00177         void RndRemoveDefect();
00179         void RemoveAllDefects();
00181         Atom* & operator[](Int_t i) { return (Atom*&)(*defects)[i]; }
00182         
00183     protected:
00184         Int_t Nx;           
00185         Int_t Ny;           
00186         Int_t N;            
00187         Int_t Nu;           
00188         Int_t defCount;     
00189         Int_t defArrayCount;
00190         Double_t c;         
00191         Layer *pLayer;      
00192         Atom **atoms;       
00193         TObjArray *defects; 
00194         Bool_t bInfo;       
00195         Style_t atomShape;
00196         Style_t defectShape;
00197         Size_t atomSize;
00198         Size_t defectSize;
00199         Color_t atomColor;
00200         Color_t defectColor;
00201 };
00202 
00203 
00204 class SquareLattice : public Lattice
00205 {
00206     public:
00207         SquareLattice(Layer *pLayer, Int_t Nx, Int_t Ny, Double_t c);
00208         virtual ~SquareLattice();
00209         
00210         void CreateLattice();
00211         Atom* GetAtomNeighbor(Atom*);
00212 };
00213 
00214 
00215 class HexLattice : public Lattice
00216 {
00217     public:
00218         HexLattice(Layer *pLayer, Int_t Nx, Int_t Ny, Double_t c);
00219         virtual ~HexLattice();
00220         
00221         void CreateLattice();
00222         Atom* GetAtomNeighbor(Atom*);
00223 };
00224 
00225 #endif // _LATTICE_H_

Generated on Sun Jun 16 20:08:04 2002 for XEIS by doxygen1.2.16