MC Electron Programmgerüst
This commit is contained in:
@@ -0,0 +1,81 @@
|
|||||||
|
#ifndef PARAMETER_H
|
||||||
|
#define PARAMETER_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace blitz;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
fclose(fcat);
|
||||||
|
return(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fcat);
|
||||||
|
fprintf(stderr,"variable %s not found\n",str);
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
long int totalparticles;
|
||||||
|
double dt;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef SIMULATION_H
|
||||||
|
#define SIMULATION_H
|
||||||
|
#include <math.h>
|
||||||
|
#include "blitz/array.h"
|
||||||
|
#include "blitz/tinyvec-et.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include "particle.H"
|
||||||
|
#include "parameter.H"
|
||||||
|
|
||||||
|
using namespace blitz;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Simulation: public Parameter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Simulation();
|
||||||
|
~Simulation(){};
|
||||||
|
|
||||||
|
|
||||||
|
virtual void init(void) = 0;
|
||||||
|
virtual void inject;
|
||||||
|
|
||||||
|
void output(void);
|
||||||
|
|
||||||
|
void doit(void);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
double zeit;
|
||||||
|
double id;
|
||||||
|
int zeitschritt;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user