Added blitz
This commit is contained in:
@@ -8,16 +8,16 @@ LDFLAGS = -L../../lib
|
||||
|
||||
LOADLIBES = -lblitz -lm
|
||||
|
||||
TARGETS = mcelectronen
|
||||
TARGETS = mcelectron
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
mcelectronen: main.o katrin.o simulation.o particle.o
|
||||
$(CXX) -o $@ $^ $(LDFLAGS) $(LOADLIBES)
|
||||
mcelectron: main.o katrin.o simulation.o particle.o
|
||||
$(CXX) -o $@ $^ $(LDFLAGS) $(LOADLIBES)
|
||||
|
||||
%.o : %.cpp
|
||||
$(CXX) -Wno-write-strings -c $< $(CXXFLAGS) -o $@
|
||||
|
||||
clean:
|
||||
$(X_CLEAN) mcelectronen
|
||||
rm *.o mcelectron
|
||||
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "blitz/array.h"
|
||||
#include "blitz/tinyvec2.h"
|
||||
|
||||
#include <math.h>
|
||||
#include "particle.h"
|
||||
#include "parameter.h"
|
||||
@@ -16,15 +20,16 @@
|
||||
|
||||
TinyVector<double,3> katrin::magneticfield(TinyVector<double,3>)
|
||||
{
|
||||
return((0,0,BFeld));
|
||||
return(0,0,magFieldSetValue);
|
||||
}
|
||||
|
||||
double katrin::tritiumdichte(TinyVector<double,3>)
|
||||
{
|
||||
return(starttritiumdichte);
|
||||
return(0);
|
||||
}
|
||||
|
||||
TinyVector<double,3> electricfield(TinyVector<double,3>)
|
||||
{
|
||||
return((0,0,0));
|
||||
return(0,0,0);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,22 +7,28 @@
|
||||
|
||||
#ifndef katrin_h
|
||||
#define katrin_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "blitz/array.h"
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "particle.h"
|
||||
#include "parameter.h"
|
||||
|
||||
class katrin: public Parameter
|
||||
{
|
||||
public:
|
||||
katrin(){};
|
||||
~katrin(){};
|
||||
TinyVector<double,3> magneticfield(TinyVector<double,3>);
|
||||
double tritiumdichte(TinyVector<double,3>);
|
||||
TinyVector<double,3> electricfield(TinyVector<double,3>);
|
||||
katrin(){};
|
||||
virtual ~katrin(){};
|
||||
|
||||
TinyVector<double,3> magneticfield(TinyVector<double,3>);
|
||||
TinyVector<double,3> electricfield(TinyVector<double,3>);
|
||||
double tritiumdichte(TinyVector<double,3>);
|
||||
};
|
||||
|
||||
|
||||
#endif /* katrin_h */
|
||||
#endif
|
||||
|
||||
Binary file not shown.
@@ -7,16 +7,34 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "blitz/array.h"
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include <math.h>
|
||||
#include "particle.h"
|
||||
|
||||
|
||||
#include "parameter.h"
|
||||
#include "simulation.h"
|
||||
#include "particle.h"
|
||||
#include "katrin.h"
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Simulation sim;
|
||||
sim.init();
|
||||
|
||||
//Simulation SIM;
|
||||
//SIM.init();
|
||||
Uniform<double> x;
|
||||
x.seed(141244);
|
||||
cout<<x.random()<<endl;
|
||||
|
||||
|
||||
/*
|
||||
cout <<"___"<<endl;
|
||||
TinyVector<float,2> A;
|
||||
A = 1,0;
|
||||
cout << TinyVector<float,2>(1,0)<<endl;
|
||||
cout<<"___"<<endl;
|
||||
*/
|
||||
}
|
||||
|
||||
Binary file not shown.
Executable
BIN
Binary file not shown.
+57
-16
@@ -1,26 +1,67 @@
|
||||
#ifndef PARAMETER_H
|
||||
#define PARAMETER_H
|
||||
//
|
||||
// parameter.h
|
||||
//
|
||||
//
|
||||
// Created by Christian Reiling on 13.09.18.
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
#ifndef parameter_h
|
||||
#define parameter_h
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
using namespace blitz;
|
||||
using namespace std;
|
||||
|
||||
using namespace blitz;
|
||||
|
||||
class Parameter
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~Parameter(){};
|
||||
virtual ~Parameter(){};
|
||||
|
||||
Parameter()
|
||||
{
|
||||
beschissenegrosseganzzahl = (int)value("beschissenegrosseganzzahl");
|
||||
totalparticles = value("totalparticles");
|
||||
dt = value("dt");
|
||||
BFeld = value("BFeld");
|
||||
configFilePath = "parameters.cat";
|
||||
seed = (int)getVariable("seed");
|
||||
totalParticles = (long int)getVariable("totalParticles");
|
||||
dt = getVariable("dt");
|
||||
magFieldSetValue = getVariable("magFieldSetValue");
|
||||
|
||||
}
|
||||
|
||||
double value(char *str, char* ext = "cat")
|
||||
|
||||
double getVariable(string varName) // Reads Parameter from config file
|
||||
{
|
||||
string varTemp;
|
||||
double valueTemp;
|
||||
ifstream configFile;
|
||||
|
||||
configFile.open (configFilePath);
|
||||
if (!configFile)
|
||||
{
|
||||
cout<< configFilePath <<" not found " <<endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (configFile >> varTemp >> valueTemp)
|
||||
{
|
||||
if (varName.compare(varTemp)==0)
|
||||
{
|
||||
configFile.close();
|
||||
return(valueTemp);
|
||||
}
|
||||
configFile.ignore(numeric_limits<streamsize>::max(), '\n'); // jump to end of line
|
||||
}
|
||||
configFile.close();
|
||||
std::cout<< varName << " not found." <<std::endl;
|
||||
exit(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
double value(char *str, char* ext = "cat") // Reads Parameter from config file
|
||||
{
|
||||
double temp;
|
||||
char dummy[256];
|
||||
@@ -66,14 +107,14 @@ public:
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
protected:
|
||||
|
||||
long int totalparticles;
|
||||
string configFilePath;
|
||||
int seed;
|
||||
long int totalParticles;
|
||||
double dt;
|
||||
double BFeld;
|
||||
double starttritiumdichte;
|
||||
int beschissenegrosseganzzahl;
|
||||
double magFieldSetValue;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
seed 2342395328
|
||||
totalParticles 1000
|
||||
dt 5
|
||||
magFieldSetValue 2.5
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// particle.cpp
|
||||
//
|
||||
//
|
||||
// Created by Christian Reiling on 13.09.18.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "blitz/array.h"
|
||||
#include "blitz/tinyvec2.h"
|
||||
|
||||
+54
-43
@@ -1,6 +1,18 @@
|
||||
#ifndef PARTICLE_H
|
||||
#define PARTICLE_H
|
||||
//
|
||||
// particle.h
|
||||
//
|
||||
//
|
||||
// Created by Christian Reiling on 13.09.18.
|
||||
//
|
||||
|
||||
#ifndef particle_h
|
||||
#define particle_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "blitz/array.h"
|
||||
#include "blitz/tinyvec2.h"
|
||||
|
||||
@@ -11,51 +23,51 @@ using namespace blitz;
|
||||
class particle
|
||||
{
|
||||
private:
|
||||
double m;
|
||||
double q;
|
||||
long int id;
|
||||
TinyVector<double,3> v,x;
|
||||
species s;
|
||||
|
||||
double m,q,E;
|
||||
TinyVector<double,3> x,v;
|
||||
species s;
|
||||
long int id;
|
||||
public:
|
||||
/* 1. Konstruktor: Parameter explizit angegeben */
|
||||
particle(double masse, double ladung, TinyVector<double,3> ort, TinyVector<double,3> geschwindigkeit, double nummer, species sp)
|
||||
{
|
||||
m = masse;
|
||||
q = ladung;
|
||||
x = ort;
|
||||
v = geschwindigkeit;
|
||||
id = nummer;
|
||||
s = sp;
|
||||
}
|
||||
|
||||
virtual ~particle() { }
|
||||
particle(){}
|
||||
particle(double mass, double charge, double energy,TinyVector<double,3> loc, TinyVector<double,3> speed, double idnum, species spec)
|
||||
{
|
||||
m = mass;
|
||||
q = charge;
|
||||
E = energy;
|
||||
x = loc;
|
||||
v = speed;
|
||||
id = idnum;
|
||||
s = spec;
|
||||
}
|
||||
|
||||
/* 2. Konstruktor: Teilchen aus einem Array, wie es von prop() und array() geschrieben wird, herstellen */
|
||||
particle(Array<double, 1> props);
|
||||
|
||||
|
||||
particle(){}
|
||||
|
||||
virtual ~particle() { }
|
||||
|
||||
double masse() { return(m); }
|
||||
double ladung() { return(q); }
|
||||
TinyVector<double,3> ort() { return(x); }
|
||||
TinyVector<double,3> geschwindigkeit() { return(v); }
|
||||
double nummer() { return(id);}
|
||||
double winkel() { return 42; }
|
||||
TinyVector<double,3> xchange(TinyVector<double, 3> dx, int i, TinyVector<double, 3> xmin, TinyVector<double, 3> nx, TinyVector<double, 3> dvdt);
|
||||
TinyVector<double,3> vchange(TinyVector<double, 3> dv, int i);
|
||||
TinyVector<double, 3> xnew(TinyVector<double, 3> xneu) { return x = xneu; };
|
||||
TinyVector<double, 3> vnew(TinyVector<double, 3> vneu);
|
||||
|
||||
void copyol(particle*);
|
||||
Array<double,1> prop(Array<double,1>);
|
||||
virtual Array<double,1> array(); // ********************** warum virtual???? ******************************
|
||||
//particle(Array<double, 1> props); //Create from Array
|
||||
|
||||
double mass() { return(m); }
|
||||
double charge() { return(q); }
|
||||
TinyVector<double,3> loc() { return(x); }
|
||||
TinyVector<double,3> speed() { return(v); }
|
||||
double number() { return(id);}
|
||||
|
||||
TinyVector<double,3> locChange(TinyVector<double, 3> dx, int i, TinyVector<double, 3> xmin, TinyVector<double, 3> nx, TinyVector<double, 3> dvdt);
|
||||
TinyVector<double,3> speedChange(TinyVector<double, 3> dv, int i);
|
||||
TinyVector<double, 3> locSet(TinyVector<double, 3> xneu) { return x = xneu; };
|
||||
TinyVector<double, 3> speedSet(TinyVector<double, 3> vneu);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void copyol(particle*);
|
||||
Array<double,1> prop(Array<double,1>);
|
||||
virtual Array<double,1> array(); // ********************** warum virtual???? ******************************
|
||||
//void copyol(particle);
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
class particle_info : public particle {
|
||||
|
||||
private:
|
||||
@@ -106,6 +118,5 @@ public:
|
||||
return(teilchenprop);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
*/
|
||||
#endif
|
||||
|
||||
Binary file not shown.
@@ -7,15 +7,66 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "blitz/array.h"
|
||||
#include "blitz/tinyvec2.h"
|
||||
|
||||
#include <math.h>
|
||||
#include "particle.h"
|
||||
#include "parameter.h"
|
||||
#include "simulation.h"
|
||||
|
||||
|
||||
|
||||
void init(void)
|
||||
void Simulation::init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Simulation::doit()
|
||||
{
|
||||
double totalcross, mfp;
|
||||
TinyVector <double,3> alterort, neuerort;
|
||||
while (injectedparticles < totalParticles)
|
||||
{
|
||||
if (teilchenliste.size() == 0 )
|
||||
{
|
||||
inject();
|
||||
}
|
||||
for(teilcheniterator = teilchenliste.begin();
|
||||
teilcheniterator != teilchenliste.end();
|
||||
teilcheniterator++)
|
||||
{
|
||||
totalcross = calctotalcross(*teilcheniterator);
|
||||
mfp = 1/totalcross/KAT.tritiumdichte(teilcheniterator->ort());
|
||||
alterort = teilcheniterator->ort();
|
||||
move (*teilcheniterator, mfp);
|
||||
|
||||
//selectprocess(*teilcheniterator);
|
||||
//if (alterort(2) > 0.5)
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Simulation::inject()
|
||||
{
|
||||
TinyVector<double,3> ort, geschwindigkeit;
|
||||
ort = 0,0,0;
|
||||
geschwindigkeit = 1,0,0;
|
||||
particle egon(9.109383e-28,1,ort, geschwindigkeit,injectedparticles,electron);
|
||||
injectedparticles++;
|
||||
|
||||
}
|
||||
void Simulation::move(particle inputparticle, double mfp)
|
||||
{
|
||||
//Borispush
|
||||
}
|
||||
|
||||
|
||||
|
||||
double calctotalcross(particle inputparticle)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -1,37 +1,63 @@
|
||||
#ifndef SIMULATION_H
|
||||
#define SIMULATION_H
|
||||
//
|
||||
// simulation.h
|
||||
//
|
||||
//
|
||||
// Created by Christian Reiling on 13.09.18.
|
||||
//
|
||||
|
||||
#ifndef simulation_h
|
||||
#define simulation_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "blitz/array.h"
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include <math.h>
|
||||
#include <random/uniform.h>
|
||||
|
||||
#include "particle.h"
|
||||
#include "parameter.h"
|
||||
#include "katrin.h"
|
||||
|
||||
using namespace blitz;
|
||||
|
||||
using namespace std;
|
||||
using namespace ranlib;
|
||||
|
||||
|
||||
class Simulation: public Parameter
|
||||
{
|
||||
public:
|
||||
|
||||
Simulation();
|
||||
~Simulation(){};
|
||||
|
||||
~Simulation(){};
|
||||
Simulation()
|
||||
{
|
||||
injectedparticles = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void init(void);
|
||||
void inject();
|
||||
|
||||
void doit(void);
|
||||
void inject();
|
||||
void move(particle inputparticle, double mfp);
|
||||
void output(void);
|
||||
|
||||
void output(void);
|
||||
|
||||
void doit(void);
|
||||
|
||||
|
||||
double calctotalcross(particle inputparticle){return 0;};
|
||||
|
||||
protected:
|
||||
|
||||
double zeit;
|
||||
double id;
|
||||
int zeitschritt;
|
||||
katrin KAT;
|
||||
|
||||
|
||||
double zeit;
|
||||
int zeitschritt;
|
||||
double id;
|
||||
|
||||
vector<particle> teilchenliste;
|
||||
int injectedparticles;
|
||||
vector<particle>::iterator teilcheniterator;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user