ESTER
Evolution STEllaire en Rotation
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
star.h
Go to the documentation of this file.
1 #ifndef _STAR_H
2 #define _STAR_H
3 
4 #include "matrix.h"
5 #include "solver.h"
6 #include "numdiff.h"
7 #include "mapping.h"
8 #include "physics.h"
9 #include "constants.h"
10 #include "parser.h"
11 #include "graphics.h"
12 #include "debug.h"
13 #include "symbolic.h"
14 
15 #include <cmath>
16 #include <vector>
17 
18 #define PRES T
19 #define LOG_PRES "log_T"
20 #define T_CONSTANT_DOMAINS
21 //#define PHOTOSPHERE 1
22 //#define KINEMATIC_VISC
23 
24 class star1d;
25 
26 class star2d {
27  protected:
28  virtual void copy(const star2d &);
29  void init1d(const star1d &A,int npts_th,int npts_ex);
30  virtual bool check_tag(const char *tag) const;
31  virtual void write_tag(OUTFILE *fp) const;
32  public:
34  const int &nr,&nth,&nex,&ndomains;
35  const matrix &r,&z,&th,&Dt,&Dt2,&zex,&Dex,&rex;
41  double X0,Y0,Z0;
42  double R,M;
43  double rhoc,Tc,pc;
45  double Ekman;
51  double m,pi_c,Lambda;
52  double surff;
53  int conv;
54  double Xc;
58  double min_core_size;
59  std::vector<int> domain_type;
60  #define RADIATIVE 0
61  #define CORE 1
62  #define CONVECTIVE 2
63 
64  struct version_struct {
65  int major, minor, rev, svn;
66  std::string name;
67  } version;
68 
69  struct units_struct {
70  double rho,p,phi,T,Omega,r,v,F;
71  } units;
72  void calc_units();
73 
74  star2d();
75  virtual ~star2d();
76  star2d(const star2d &);
77  star2d &operator=(const star2d &);
78  struct config_struct {
79  double newton_dmax;
80  int verbose;
81  int dump_iter;
82  } config;
83 
84  virtual void opacity();
85  virtual void nuclear();
86  virtual void eq_state();
87  virtual void atmosphere();
88 
89  virtual int init(const char *input_file,const char *param_file,int argc,char *argv[]);
90  virtual int check_arg(char *arg,char *val,int *change_grid);
91  virtual int read(const char *input_file, int dim = 2);
92  virtual int read_old(const char *input_file);
93  virtual void write(const char *output_file,char output_mode='b') const;
94  virtual void interp(remapper *red);
95 
96  virtual void dump_info();
97 
98  virtual void init_comp();
99 
100  virtual solver *init_solver(int nvar_add=0);
101  virtual double solve(solver *);
102  virtual void register_variables(solver *op);
103 
104  virtual void solve_poisson(solver *);
105  virtual void solve_mov(solver *);
106  virtual void solve_temp(solver *);
107  virtual void solve_dim(solver *);
108  virtual void solve_map(solver *);
109  virtual void solve_Omega(solver *);
110  virtual void solve_gsup(solver *);
111  virtual void solve_Teff(solver *);
112  virtual void solve_definitions(solver *);
113  virtual void solve_atm(solver *);
114 
115  virtual void update_map(matrix dR);
116 
117  virtual void calc_veloc();
118 
119  virtual matrix entropy() const;
120  virtual double luminosity() const;
121  virtual matrix Teff() const;
122  virtual matrix N2() const;
123  virtual matrix gsup() const;
124  virtual double virial_3P() const;
125  virtual double virial_L() const;
126  virtual double virial_W() const;
127  virtual double virial_ps() const;
128  virtual double virial() const;
129  virtual double energy_test() const;
130  virtual matrix stream() const;
131  virtual double apparent_luminosity(double i) const;
132  virtual double Lz() const;
133  virtual double Mcore() const;
134  virtual double Lzcore() const;
135  virtual matrix Rcore() const;
136 
137  virtual void fill();
138 
139  // star_map.cpp
140  virtual void remap(int ndomains,int *npts,int nth,int nex);
141  virtual bool remap_domains(int ndom, remapper &red);
142  virtual matrix find_boundaries(const matrix &logTi) const;
143  virtual std::vector<int> distribute_domains(int ndom,matrix &zif,bool check_only=false) const;
144  virtual matrix distribute_domains(int ndomains,int &conv_new,double p_cc=0) const;
145  virtual matrix find_boundaries_old(matrix pif) const;
146  virtual void check_map();
147  virtual int check_convec(double &p_cc,matrix &Rcc);
148 
149  void draw(figure *,const matrix &,int parity=0) const;
150  void drawi(figure *,const matrix &,int sr,int st,int parity=0) const;
151  void drawc(figure *,const matrix &,int ncontours,int parity=0) const;
152  void drawci(figure *,const matrix &,int sr,int st,int ncontours,int parity=0) const;
153  void spectrum(figure *,const matrix &,int parity=0) const;
154 
155  matrix kconv() const;
156  void add_kconv(solver *op,const char *eqn,const matrix &d);
157  void add_dkconv_dz(solver *op,const char *eqn,const matrix &d);
158  void kconv_common(matrix &kc,matrix &Ja,matrix &Jb,symbolic &S,sym &a_,sym &b_) const;
159 
160  virtual void check_jacobian(solver *op,const char *eqn);
161 
162  void hdf5_write(const char *filename) const;
163  int hdf5_read(const char *input_file, int dim);
164 };
165 
166 class star1d : public star2d {
167  protected:
168  virtual bool check_tag(const char *tag) const;
169  virtual void write_tag(OUTFILE *fp) const;
170  public:
171  // star1d_class.cpp
172  star1d();
173  ~star1d();
174  star1d(const star1d &);
175  star1d &operator=(const star1d &);
176  virtual int init(const char *input_file,const char *param_file,int argc,char *argv[]);
177  virtual int check_arg(char *arg,char *val,int *change_grid);
178  virtual int read_old(const char *input_file);
179  virtual int read(const char *input_file, int dim = 1);
180 
181  virtual void dump_info();
182 
183  virtual solver *init_solver(int nvar_add=0);
184  virtual void register_variables(solver *op);
185  virtual double solve(solver *);
186  virtual void solve_poisson(solver *);
187  virtual void solve_pressure(solver *);
188  virtual void solve_temp(solver *);
189  virtual void solve_dim(solver *);
190  virtual void solve_map(solver *);
191  virtual void solve_definitions(solver *);
192  virtual void solve_Teff(solver *);
193  virtual void solve_gsup(solver *);
194 
195  virtual void update_map(matrix dR);
196 
197  virtual matrix N2() const;
198  virtual double luminosity() const;
199  virtual matrix Teff() const;
200  virtual matrix gsup() const;
201 
202  virtual void fill();
203 
204  void spectrum(figure *,const matrix &,const char *line="") const;
205 
206  virtual void check_jacobian(solver *op,const char *eqn);
207 };
208 
209 class star_evol : public star2d {
210 protected:
212 public:
213  bool converged;
214  double Lz_obj;
215  star_evol();
216  star_evol(const star2d &);
217  virtual void fill();
218  virtual int read(const char *input_file, int dim = 2);
219  virtual solver *init_solver(int nvar_add=0);
220  virtual void register_variables(solver *op);
221  virtual void solve_Omega(solver *);
222  // void init_comp();
223 };
224 
225 #endif
226 
227 
virtual void calc_veloc()
Definition: star2d_solvers.cpp:67
void draw(figure *, const matrix &, int parity=0) const
Definition: star2d_extra.cpp:4
virtual double apparent_luminosity(double i) const
Definition: star2d_extra.cpp:204
virtual void register_variables(solver *op)
Definition: star1d_solvers.cpp:50
virtual void solve_dim(solver *)
Writes the equations for the dimensional quantities (T_c, rho_c, R, etc.)
Definition: star2d_solvers.cpp:855
double Lz_obj
Definition: star.h:214
virtual void check_jacobian(solver *op, const char *eqn)
Routine to check the Jacobian matrix.
Definition: star1d_solvers.cpp:693
int conv
Definition: star.h:53
bool converged
Definition: star.h:213
virtual void solve_Omega(solver *)
Equation setting the equatorial angular velocity.
Definition: star_evol.cpp:53
void calc_units()
Definition: star2d_extra.cpp:34
void add_kconv(solver *op, const char *eqn, const matrix &d)
Definition: convection.cpp:139
void kconv_common(matrix &kc, matrix &Ja, matrix &Jb, symbolic &S, sym &a_, sym &b_) const
void drawci(figure *, const matrix &, int sr, int st, int ncontours, int parity=0) const
Definition: star2d_extra.cpp:22
const matrix_block_diag & D
Definition: star.h:36
double Tc
Definition: star.h:43
opa_struct opa
Definition: star.h:46
double pc
Definition: star.h:43
virtual void solve_gsup(solver *)
Equation giving the effective surface gravity gsup gsup=(- P)/rho.
Definition: star2d_solvers.cpp:1076
virtual void solve_Teff(solver *)
Equation setting the surface effective temperature Derived from sigma T_e^4 = -xi.
Definition: star2d_solvers.cpp:1113
virtual void solve_gsup(solver *)
Equation giving the effective surface gravity gsup gsup=(- P)/rho.
Definition: star1d_solvers.cpp:634
virtual solver * init_solver(int nvar_add=0)
Definition: star1d_solvers.cpp:33
A solver object stores a system of equation to solve.
Definition: solver.h:73
int svn
Definition: star.h:65
Definition: physics.h:11
int stratified_comp
Definition: star.h:57
virtual int read_old(const char *input_file)
Definition: star2d_class.cpp:619
virtual void solve_temp(solver *)
Writes temperature and luminosity equations and interface conditions into the solver.
Definition: star1d_solvers.cpp:318
const matrix & th
Definition: star.h:35
double Y0
Definition: star.h:41
virtual void dump_info()
Definition: star2d_class.cpp:1071
const int & ndomains
Definition: star.h:34
const int & nex
Definition: star.h:34
double X0
Definition: star.h:41
virtual void init_comp()
Definition: star2d_solvers.cpp:38
The matrix class is used to facilitate the work with regular dense matrices.
Definition: matrix.h:9
virtual void update_map(matrix dR)
Definition: star1d_solvers.cpp:175
virtual double virial_W() const
Definition: star2d_extra.cpp:166
double m
Definition: star.h:51
virtual int read(const char *input_file, int dim=2)
Definition: star2d_class.cpp:480
virtual double solve(solver *)
Performs one step of the Newton algorithm to compute the star's internal structure.
Definition: star2d_solvers.cpp:142
Definition: symbolic.h:281
matrix vr
Definition: star.h:39
virtual void nuclear()
Definition: star_phys.cpp:20
const int & nr
Definition: star.h:34
The matrix_block_diag class is used to store block diagonal matrices.
Definition: matrix.h:202
virtual double virial() const
Definition: star2d_extra.cpp:185
Definition: star.h:64
virtual int read(const char *input_file, int dim=1)
Definition: star1d_class.cpp:163
std::vector< int > domain_type
Definition: star.h:59
double M
Definition: star.h:42
double Omega_bk
Definition: star.h:44
virtual matrix find_boundaries(const matrix &logTi) const
Definition: star_map.cpp:152
virtual int read(const char *input_file, int dim=2)
Definition: star_evol.cpp:16
double rho
Definition: star.h:70
double Omegac
Definition: star.h:44
virtual void solve_atm(solver *)
Equation setting the 'simple' atmosphere model equations To be checked.
Definition: star2d_solvers.cpp:1151
eos_struct eos
Definition: star.h:48
virtual void solve_temp(solver *)
Writes temperature and luminosity equations and interface conditions into the solver.
Definition: star2d_solvers.cpp:614
nuc_struct nuc
Definition: star.h:47
struct star2d::units_struct units
Definition: symbolic.h:73
virtual void interp(remapper *red)
Definition: star2d_class.cpp:933
void init1d(const star1d &A, int npts_th, int npts_ex)
Definition: star2d_class.cpp:898
virtual ~star2d()
Definition: star2d_class.cpp:30
double phi
Definition: star.h:70
virtual int check_arg(char *arg, char *val, int *change_grid)
Definition: star1d_class.cpp:279
Definition: physics.h:7
double Z0
Definition: star.h:41
Definition: star.h:26
double R
Definition: star.h:42
virtual matrix gsup() const
Definition: star2d_extra.cpp:149
virtual void solve_mov(solver *)
Writes movement and vorticity equations into the solver.
Definition: star2d_solvers.cpp:429
virtual int check_arg(char *arg, char *val, int *change_grid)
Definition: star2d_class.cpp:946
Definition: mapping.h:82
virtual matrix N2() const
Definition: star1d_extra.cpp:55
Definition: physics.h:15
double r
Definition: star.h:70
double Xc
Definition: star.h:54
Definition: star.h:166
virtual void solve_dim(solver *)
Writes the equations for the dimensional quantities (T_c, rho_c, R, etc.)
Definition: star1d_solvers.cpp:514
double v
Definition: star.h:70
int major
Definition: star.h:65
const matrix & z
Definition: star.h:35
Definition: star.h:78
virtual matrix N2() const
Definition: star2d_extra.cpp:91
mapping map
Definition: star.h:33
virtual void solve_Teff(solver *)
Equation setting the surface effective temperature Derived from sigma T_e^4 = -xi.
Definition: star1d_solvers.cpp:663
star2d & operator=(const star2d &)
Definition: star2d_class.cpp:41
virtual void fill()
Initialize star's chemical composition, equation of state, opacity, nuclear reaction, mass definition, pi_c, Lambda, velocity, units, atmosphere, flatness, scaled keplerian angular velocity.
Definition: star2d_solvers.cpp:11
matrix rho
Definition: star.h:37
const matrix & r
Definition: star.h:35
star1d()
Definition: star1d_class.cpp:7
virtual matrix gsup() const
Definition: star1d_extra.cpp:48
virtual double virial_ps() const
Definition: star2d_extra.cpp:179
int env_convec
Definition: star.h:56
Definition: parser.h:32
int verbose
Definition: star.h:80
virtual solver * init_solver(int nvar_add=0)
Definition: star2d_solvers.cpp:78
std::string name
Definition: star.h:66
virtual double virial_L() const
Definition: star2d_extra.cpp:172
virtual double Lzcore() const
Definition: star2d_extra.cpp:71
virtual matrix Teff() const
Definition: star1d_extra.cpp:39
atm_struct atm
Definition: star.h:49
int core_convec
Definition: star.h:55
virtual void write(const char *output_file, char output_mode='b') const
Definition: star2d_class.cpp:198
void spectrum(figure *, const matrix &, int parity=0) const
Definition: star2d_extra.cpp:29
int minor
Definition: star.h:65
composition_map comp
Definition: star.h:40
matrix G
Definition: star.h:39
virtual double luminosity() const
Definition: star1d_extra.cpp:33
Definition: star.h:209
virtual double Lz() const
Definition: star2d_extra.cpp:52
virtual void remap(int ndomains, int *npts, int nth, int nex)
Definition: star_map.cpp:8
Definition: mapping.h:13
star2d()
Definition: star2d_class.cpp:11
double pi_c
Definition: star.h:51
double surff
Definition: star.h:52
virtual bool remap_domains(int ndom, remapper &red)
Definition: star_map.cpp:25
double Omega
Definition: star.h:44
virtual void register_variables(solver *op)
Definition: star_evol.cpp:46
struct star2d::version_struct version
star_evol()
Definition: star_evol.cpp:6
void drawc(figure *, const matrix &, int ncontours, int parity=0) const
Definition: star2d_extra.cpp:16
int rev
Definition: star.h:65
const matrix & Dex
Definition: star.h:35
virtual std::vector< int > distribute_domains(int ndom, matrix &zif, bool check_only=false) const
Definition: star_map.cpp:75
virtual solver * init_solver(int nvar_add=0)
Definition: star_evol.cpp:42
void drawi(figure *, const matrix &, int sr, int st, int parity=0) const
Definition: star2d_extra.cpp:10
matrix Ts
Definition: star.h:50
virtual double energy_test() const
Definition: star2d_extra.cpp:191
matrix ps
Definition: star.h:50
virtual void solve_map(solver *)
Part of the Jacobian associated with the mapping There are geometrical relations and physical relatio...
Definition: star2d_solvers.cpp:931
~star1d()
Definition: star1d_class.cpp:11
virtual void solve_poisson(solver *)
Writes Poisson equation and interface conditions into the solver.
Definition: star2d_solvers.cpp:321
void hdf5_write(const char *filename) const
Definition: star2d_class.cpp:120
double T
Definition: star.h:70
virtual void check_map()
Definition: star_map.cpp:263
virtual bool check_tag(const char *tag) const
Definition: star2d_class.cpp:612
matrix phiex
Definition: star.h:38
virtual bool check_tag(const char *tag) const
Definition: star1d_class.cpp:34
const matrix & Dt2
Definition: star.h:35
virtual void update_map(matrix dR)
Definition: star2d_solvers.cpp:241
Definition: star.h:69
matrix w
Definition: star.h:39
double Lambda
Definition: star.h:51
virtual void register_variables(solver *op)
Definition: star2d_solvers.cpp:94
matrix p
Definition: star.h:37
int dim
Definition: gen_output.cpp:13
virtual void solve_definitions(solver *)
insert the definitions depending on opacity and eos tables into the solver, and the definitions used ...
Definition: star2d_solvers.cpp:259
virtual int init(const char *input_file, const char *param_file, int argc, char *argv[])
Definition: star2d_class.cpp:760
virtual double virial_3P() const
Definition: star2d_extra.cpp:160
matrix kconv() const
Definition: convection.cpp:59
Definition: graphics.h:7
virtual void write_tag(OUTFILE *fp) const
Definition: star1d_class.cpp:27
virtual void eq_state()
Definition: star_phys.cpp:30
virtual matrix find_boundaries_old(matrix pif) const
Definition: star_map.cpp:225
virtual int init(const char *input_file, const char *param_file, int argc, char *argv[])
Definition: star1d_class.cpp:168
virtual void solve_definitions(solver *)
insert the definitions depending on opacity and eos tables into the solver, and the definitions used ...
Definition: star1d_solvers.cpp:193
virtual void atmosphere()
Definition: star_phys.cpp:47
const int & nth
Definition: star.h:34
Definition: physics.h:20
int hdf5_read(const char *input_file, int dim)
Definition: star2d_class.cpp:287
virtual matrix entropy() const
Definition: star2d_extra.cpp:106
virtual double Mcore() const
Definition: star2d_extra.cpp:60
virtual void solve_map(solver *)
Part of the Jacobian associated with the mapping There are geometrical relations and physical relatio...
Definition: star1d_solvers.cpp:583
int dump_iter
Definition: star.h:81
virtual void fill()
Initialize star's chemical composition, equation of state, opacity, nuclear reaction, mass definition, pi_c, Lambda, velocity, units, atmosphere, flatness, scaled keplerian angular velocity.
Definition: star_evol.cpp:24
double min_core_size
Definition: star.h:58
double rhoc
Definition: star.h:43
virtual void solve_poisson(solver *)
Writes Poisson equation and interface conditions into the solver.
Definition: star1d_solvers.cpp:235
double F
Definition: star.h:70
Definition: physics.h:25
virtual int check_convec(double &p_cc, matrix &Rcc)
Definition: star_map.cpp:307
const matrix & zex
Definition: star.h:35
struct star2d::config_struct config
virtual void dump_info()
Definition: star1d_class.cpp:294
double Ekman
Definition: star.h:45
matrix vt
Definition: star.h:39
virtual matrix Teff() const
Definition: star2d_extra.cpp:138
matrix T
Definition: star.h:37
virtual void opacity()
Definition: star_phys.cpp:10
virtual double luminosity() const
Definition: star2d_extra.cpp:46
virtual void solve_Omega(solver *)
Equation setting the equatorial angular velocity.
Definition: star2d_solvers.cpp:1049
virtual void solve_pressure(solver *)
Definition: star1d_solvers.cpp:279
virtual void check_jacobian(solver *op, const char *eqn)
Routine to check the Jacobian matrix.
Definition: star2d_solvers.cpp:1194
const matrix & Dt
Definition: star.h:35
void spectrum(figure *, const matrix &, const char *line="") const
Definition: star1d_extra.cpp:4
virtual void copy(const star2d &)
Definition: star2d_class.cpp:48
void add_dkconv_dz(solver *op, const char *eqn, const matrix &d)
Definition: convection.cpp:149
matrix phi
Definition: star.h:37
double Omega
Definition: star.h:70
virtual int read_old(const char *input_file)
Definition: star1d_class.cpp:40
double p
Definition: star.h:70
star1d & operator=(const star1d &)
Definition: star1d_class.cpp:19
double newton_dmax
Definition: star.h:79
virtual void fill()
Initialize star's chemical composition, equation of state, opacity, nuclear reaction, mass definition, pi_c, Lambda, velocity, units, atmosphere, flatness, scaled keplerian angular velocity.
Definition: star1d_solvers.cpp:7
virtual void write_tag(OUTFILE *fp) const
Definition: star2d_class.cpp:604
virtual double solve(solver *)
Performs one step of the Newton algorithm to compute the star's internal structure.
Definition: star1d_solvers.cpp:88
virtual matrix stream() const
Definition: star2d_extra.cpp:279
bool comp_inited
Definition: star.h:211
const matrix & rex
Definition: star.h:35
virtual matrix Rcore() const
Definition: star2d_extra.cpp:82