cpp and h files added#
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// katrin.cpp
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 13.09.18.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "blitz/array.h"
|
||||||
|
#include "blitz/tinyvec2.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include "particle.h"
|
||||||
|
#include "parameter.h"
|
||||||
|
#include "katrin.h"
|
||||||
|
|
||||||
|
TinyVector<double,3> katrin::magneticfield(TinyVector<double,3>)
|
||||||
|
{
|
||||||
|
return((0,0,BFeld));
|
||||||
|
}
|
||||||
|
|
||||||
|
double katrin::tritiumdichte(TinyVector<double,3>)
|
||||||
|
{
|
||||||
|
return(starttritiumdichte);
|
||||||
|
}
|
||||||
|
TinyVector<double,3> electricfield(TinyVector<double,3>)
|
||||||
|
{
|
||||||
|
return((0,0,0));
|
||||||
|
}
|
||||||
|
|
||||||
@@ -9,12 +9,12 @@
|
|||||||
#define katrin_h
|
#define katrin_h
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
#include "blitz/tinyvec-et.h"
|
#include "blitz/tinyvec2.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "particle.H"
|
#include "particle.h"
|
||||||
#include "parameter.H"
|
#include "parameter.h"
|
||||||
|
|
||||||
class katrin: public parameter
|
class katrin: public Parameter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
katrin(){};
|
katrin(){};
|
||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
TinyVector<double,3> magneticfield(TinyVector<double,3>);
|
TinyVector<double,3> magneticfield(TinyVector<double,3>);
|
||||||
double tritiumdichte(TinyVector<double,3>);
|
double tritiumdichte(TinyVector<double,3>);
|
||||||
TinyVector<double,3> electricfield(TinyVector<double,3>);
|
TinyVector<double,3> electricfield(TinyVector<double,3>);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* katrin_h */
|
#endif /* katrin_h */
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// main.cpp
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 13.09.18.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "blitz/array.h"
|
||||||
|
#include "blitz/tinyvec2.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include "particle.h"
|
||||||
|
#include "parameter.h"
|
||||||
|
#include "simulation.h"
|
||||||
|
#include "katrin.h"
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
Simulation sim;
|
||||||
|
sim.init();
|
||||||
|
}
|
||||||
+59
-60
@@ -11,70 +11,69 @@ class Parameter
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~Parameter(){};
|
virtual ~Parameter(){};
|
||||||
Parameter()
|
Parameter()
|
||||||
{
|
|
||||||
beschissenegrosseganzzahl = (int)value("beschissenegrosseganzzahl");
|
|
||||||
|
|
||||||
totalparticles = value("totalparticles");
|
|
||||||
|
|
||||||
dt = value("dt");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
double value(char *str, char* ext = "cat")
|
|
||||||
{
|
|
||||||
double temp;
|
|
||||||
char dummy[256];
|
|
||||||
char fname[256],*pname;
|
|
||||||
FILE *fcat;
|
|
||||||
|
|
||||||
if (getenv("poub") == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr,"Environment variable %s not defined.\n","poub");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
strcpy(fname, getenv("poub"));
|
|
||||||
pname = getenv("pname");
|
|
||||||
if (pname == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr,"Environment variable %s not defined.\n","pname");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (!ext)
|
|
||||||
{
|
|
||||||
ext = "cat";
|
|
||||||
}
|
|
||||||
sprintf(fname,"%s/%s.%s",getenv("poub"),getenv("pname"), ext);
|
|
||||||
if (!(fcat = fopen(fname, "r")))
|
|
||||||
{
|
|
||||||
fprintf(stderr,"value: cannot open file %s\n",fname);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
while (!feof(fcat))
|
|
||||||
{
|
|
||||||
// fscanf(fcat, "'%s%*[^']'%F%*[^']",dummy,&temp); 1
|
|
||||||
fscanf(fcat, "%s = %lf", dummy, &temp);
|
|
||||||
// if (strncmp(dummy, str,strlen(str)) == 0) {
|
|
||||||
if (strcmp(dummy, str) == 0)
|
|
||||||
{
|
{
|
||||||
fclose(fcat);
|
beschissenegrosseganzzahl = (int)value("beschissenegrosseganzzahl");
|
||||||
return(temp);
|
totalparticles = value("totalparticles");
|
||||||
|
dt = value("dt");
|
||||||
|
BFeld = value("BFeld");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fclose(fcat);
|
double value(char *str, char* ext = "cat")
|
||||||
fprintf(stderr,"variable %s not found\n",str);
|
{
|
||||||
exit(1);
|
double temp;
|
||||||
|
char dummy[256];
|
||||||
return 0;
|
char fname[256],*pname;
|
||||||
}
|
FILE *fcat;
|
||||||
|
|
||||||
|
if (getenv("poub") == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Environment variable %s not defined.\n","poub");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
strcpy(fname, getenv("poub"));
|
||||||
|
pname = getenv("pname");
|
||||||
|
if (pname == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Environment variable %s not defined.\n","pname");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (!ext)
|
||||||
|
{
|
||||||
|
ext = "cat";
|
||||||
|
}
|
||||||
|
sprintf(fname,"%s/%s.%s",getenv("poub"),getenv("pname"), ext);
|
||||||
|
if (!(fcat = fopen(fname, "r")))
|
||||||
|
{
|
||||||
|
fprintf(stderr,"value: cannot open file %s\n",fname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
while (!feof(fcat))
|
||||||
|
{
|
||||||
|
// fscanf(fcat, "'%s%*[^']'%F%*[^']",dummy,&temp); 1
|
||||||
|
fscanf(fcat, "%s = %lf", dummy, &temp);
|
||||||
|
// if (strncmp(dummy, str,strlen(str)) == 0) {
|
||||||
|
if (strcmp(dummy, str) == 0)
|
||||||
|
{
|
||||||
|
fclose(fcat);
|
||||||
|
return(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fcat);
|
||||||
|
fprintf(stderr,"variable %s not found\n",str);
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
long int totalparticles;
|
long int totalparticles;
|
||||||
double dt;
|
double dt;
|
||||||
|
double BFeld;
|
||||||
|
double starttritiumdichte;
|
||||||
|
int beschissenegrosseganzzahl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#ifndef PARTICLE_H
|
#ifndef PARTICLE_H
|
||||||
#define PARTICLE_H
|
#define PARTICLE_H
|
||||||
|
|
||||||
#include "clist.H"
|
|
||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
#include "blitz/tinyvec-et.h"
|
#include "blitz/tinyvec2.h"
|
||||||
|
|
||||||
typedef species enum {electron, positron, proton, tritium, tritium2, helium, deuterium, dt};
|
typedef enum species{electron, positron, proton, tritium, tritium2, helium, deuterium, dt}species;
|
||||||
|
|
||||||
using namespace blitz;
|
using namespace blitz;
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ class particle
|
|||||||
private:
|
private:
|
||||||
double m;
|
double m;
|
||||||
double q;
|
double q;
|
||||||
double id;
|
long int id;
|
||||||
TinyVector<double,3> v,x;
|
TinyVector<double,3> v,x;
|
||||||
species s;
|
species s;
|
||||||
|
|
||||||
@@ -109,38 +108,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class particle_mitmue : public particle { private:
|
|
||||||
double mue;
|
|
||||||
public:
|
|
||||||
particle_mitmue(double masse, double ladung, TinyVector<double,3> ort, TinyVector<double,3> geschwindigkeit, double nummer, double winkel):particle(masse, ladung, ort, geschwindigkeit, nummer)
|
|
||||||
{
|
|
||||||
mue = winkel;
|
|
||||||
}
|
|
||||||
particle_mitmue() { }
|
|
||||||
~particle_mitmue() { }
|
|
||||||
|
|
||||||
double winkel() { return(mue); }
|
|
||||||
double muenew(double mueneu);
|
|
||||||
void copyol(particle_mitmue* teilchen)
|
|
||||||
{
|
|
||||||
particle::copyol( teilchen);
|
|
||||||
mue = teilchen->winkel();
|
|
||||||
}
|
|
||||||
|
|
||||||
Array<double,1> array () // *********************** auslagern in .cpp **************************
|
|
||||||
{
|
|
||||||
Array<double,1> teilchenprop;
|
|
||||||
TinyVector<int,1> temp;
|
|
||||||
temp=10;
|
|
||||||
teilchenprop.resize(temp);
|
|
||||||
|
|
||||||
particle::prop(teilchenprop);
|
|
||||||
mue = this->winkel();
|
|
||||||
teilchenprop(9)=mue;
|
|
||||||
|
|
||||||
return(teilchenprop);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// simulation.cpp
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 13.09.18.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "blitz/array.h"
|
||||||
|
#include "blitz/tinyvec2.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include "particle.h"
|
||||||
|
#include "parameter.h"
|
||||||
|
#include "simulation.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void init(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#ifndef SIMULATION_H
|
#ifndef SIMULATION_H
|
||||||
#define SIMULATION_H
|
#define SIMULATION_H
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
#include "blitz/tinyvec-et.h"
|
#include "blitz/tinyvec2.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "particle.H"
|
#include "particle.h"
|
||||||
#include "parameter.H"
|
#include "parameter.h"
|
||||||
|
|
||||||
using namespace blitz;
|
using namespace blitz;
|
||||||
|
|
||||||
@@ -19,8 +19,8 @@ public:
|
|||||||
~Simulation(){};
|
~Simulation(){};
|
||||||
|
|
||||||
|
|
||||||
virtual void init(void) = 0;
|
void init(void);
|
||||||
virtual void inject;
|
void inject();
|
||||||
|
|
||||||
void output(void);
|
void output(void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user