1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/*
This file is part of LPIC++, a particle-in-cell code for
simulating the interaction of laser light with plasma.
Copyright (C) 1994-1997 Roland Lichters
LPIC++ is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef DOMAIN_H
#define DOMAIN_H
#include <common.h>
#include <fstream>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <error.h>
#include <cell.h>
#include <particle.h>
#include <parameter.h>
#include <readfile.h>
struct ramp {
int length; // linear ramp length (form=0) or inner scale length (form=1 or 2) or inner ramp length (form=3) in cells
int form; // 0 = linear; 1 = exponential; 2 = double exp; 3 = lin-const-lin
int length2; // outer scale length (form=2) or outer ramp length (form=3) in cells
int cutoff; // max ramplength (<0 <=> disabled) in cells
int gluepos; // glue-point between the two exp-ramps (form=2) -> length of the inner ramp in cells; or inner point of outer linear ramp (form=3)
double middens; // density of the constant portion in the middle (form=3) in fractions of ni
double calculate_density(int position);
};
class input_domain {
private:
char errname[filename_size];
public:
int Q_restart; // start from t>0, using restart files
char restart_file[filename_size];
int Q_restart_save;
int n_domains; // grid
int cells;
int cells_per_wl;
int cells_left;
ramp lramp; // lefthand plasma ramp
ramp rramp; // righthand plasma ramp
int cells_plasma;
double dx;
double ux0; // initial momentum in x-direction
double n_ion_over_nc; // plasma density
double n_el_over_nc;
int nsp; // particles
int *ppc;
int *fix;
double *z, *zmax, *m;
double *vtherm;
double angle; // angles of incidence
double Gamma, Beta; // Lorentz transformation
int spp; // steps per laser period
readfile rf;
input_domain( parameter &p );
void save( parameter &p );
};
//////////////////////////////////////////////////////////////////////////////////////////
class domain {
private:
char errname[filename_size];
int domain_number;
int n_domains;
char path[filename_size];
input_domain input;
void restart_configuration( void );
void set_boundaries( void );
void chain_cells( void );
void init_cells( void );
void chain_particles( void );
void init_particles( void );
double gauss_rand48( void );
double exponential_rand( double ); // ## exponential velocity distribution
public:
int n_left; // cell number at the left boundary
int n_right; // cell number at the right boundary
int n_cells; // number of cells in this domain
double dx; // cell width
struct cell *Lbuf; // lhs: left buffer cell left of left
struct cell *lbuf; // right buffer left of left
struct cell *left; // pointer to the first occupied cell
struct cell *right; // pointer to the last occupied cell
struct cell *rbuf; // rhs: left buffer cell right of right
struct cell *Rbuf; // right buffer right of right
struct cell *dummy; // definitely the last one
int n_el; // # of electrons
int n_ion; // # of ions
int n_part; // total # particles
domain( parameter &p );
void count_particles( void );
void check( void );
void reo_to_prev( int request_to_prev, int *cells_to_prev, int *parts_to_prev );
void reo_to_next( int request_to_next, int *cells_to_next, int *parts_to_next );
void reo_delete_to_prev( int cells_to_prev, int parts_to_prev );
void reo_delete_to_next( int cells_to_next, int parts_to_next );
void reo_alloc_from_prev( int cells_from_prev, int parts_from_prev );
void reo_alloc_from_next( int cells_from_next, int parts_from_next );
void reo_update_n_el_n_ion( int el_count, int ion_count );
};
#endif
|