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
|
||||
#include <math.h>
|
||||
#include "blitz/array.h"
|
||||
#include "blitz/tinyvec-et.h"
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include <math.h>
|
||||
#include "particle.H"
|
||||
#include "parameter.H"
|
||||
#include "particle.h"
|
||||
#include "parameter.h"
|
||||
|
||||
class katrin: public parameter
|
||||
class katrin: public Parameter
|
||||
{
|
||||
public:
|
||||
katrin(){};
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
TinyVector<double,3> magneticfield(TinyVector<double,3>);
|
||||
double tritiumdichte(TinyVector<double,3>);
|
||||
TinyVector<double,3> electricfield(TinyVector<double,3>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#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:
|
||||
|
||||
virtual ~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)
|
||||
virtual ~Parameter(){};
|
||||
Parameter()
|
||||
{
|
||||
fclose(fcat);
|
||||
return(temp);
|
||||
beschissenegrosseganzzahl = (int)value("beschissenegrosseganzzahl");
|
||||
totalparticles = value("totalparticles");
|
||||
dt = value("dt");
|
||||
BFeld = value("BFeld");
|
||||
}
|
||||
}
|
||||
fclose(fcat);
|
||||
fprintf(stderr,"variable %s not found\n",str);
|
||||
exit(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
return(temp);
|
||||
}
|
||||
}
|
||||
fclose(fcat);
|
||||
fprintf(stderr,"variable %s not found\n",str);
|
||||
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
long int totalparticles;
|
||||
double dt;
|
||||
long int totalparticles;
|
||||
double dt;
|
||||
double BFeld;
|
||||
double starttritiumdichte;
|
||||
int beschissenegrosseganzzahl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#ifndef PARTICLE_H
|
||||
#define PARTICLE_H
|
||||
|
||||
#include "clist.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;
|
||||
|
||||
@@ -14,7 +13,7 @@ class particle
|
||||
private:
|
||||
double m;
|
||||
double q;
|
||||
double id;
|
||||
long int id;
|
||||
TinyVector<double,3> v,x;
|
||||
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
|
||||
|
||||
@@ -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
|
||||
#include <math.h>
|
||||
#include "blitz/array.h"
|
||||
#include "blitz/tinyvec-et.h"
|
||||
#include "blitz/tinyvec2.h"
|
||||
#include <math.h>
|
||||
#include "particle.H"
|
||||
#include "parameter.H"
|
||||
#include "particle.h"
|
||||
#include "parameter.h"
|
||||
|
||||
using namespace blitz;
|
||||
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
~Simulation(){};
|
||||
|
||||
|
||||
virtual void init(void) = 0;
|
||||
virtual void inject;
|
||||
void init(void);
|
||||
void inject();
|
||||
|
||||
void output(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user