//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // Program electrons //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* #include "cip.h" #include "vector2.h" #include "nxgraph.h" //---- physical constants const double Mele = 1.0; // mass of an electron const double Eele = 1.0; // charge of an electron const double Aint = 1.0; // coupling constant of ele-ele interaction const double Bext = 2.0; // external magnetic field const double Omega = Eele*Bext/Mele; // Larmor anglur frequency //---- experimental settings const double dT = 1.0/32; // time slice const int N = 4; // number of electrons //---- graphic setting const int WIN_WIDTH = 256; const int WIN_HEIGHT = 256; const double MAG = 64.0; //---- declaration of structure Matter struct Matter { Vector2 p, q, f; }; //---- prototypes of functions void Init( Matter M[] ); void Evolve( Matter M[], double dt ); void EvolveU( Matter M[], double dt ); void EvolveK( Matter M[], double dt ); void CalcField( Matter M[] ); double CalcEnergy( Matter M[] ); void Draw( Matter M[] ); //---- main function int main( void ) { double T=0.0; Matter M[N]; NXOpenWindow("Dance of Electrons", WIN_WIDTH, WIN_HEIGHT ); Init( M ); while( NXNoEvents() ){ Evolve( M, dT ); T += dT; Draw( M ); } NXCloseWindow(); return 0; } //---- initializes properties of electrons void Init( Matter M[] ) { for( int n=0; n