changa 3.5
Loading...
Searching...
No Matches
starform.h
Go to the documentation of this file.
1
3
4#ifndef STARFORM_HINCLUDED
5#define STARFORM_HINCLUDED
6
7#ifdef STOCH24
8#define ARRLENGTH 24
9#else
10#define ARRLENGTH 12
11#endif
12
13#include "parameters.h"
14#include "rand.h"
15#include "imf.h"
16#include "lymanwerner.h"
17
20 protected:
21 double dGmUnit; /* system mass in grams */
22 double dMsolUnit; /* system mass unit in Msol */
23 double dGmPerCcUnit; /* system density in gm/cc */
24 double dSecUnit; /* system time in seconds */
25 double dErgUnit; /* system energy in ergs */
26 double dPhysDenMin; /* Physical density minimum for star
27 formation (in system units) */
28 double dOverDenMin; /* Overdensity minimum for star formation */
29 double dTempMax; /* Form stars below this temperature
30 EVEN IF the gas is not cooling. */
31 double dSoftMin; /* Jean's length as a fraction of
32 softening at which to form stars*/
33 double dCStar; /* Star formation constant */
34 double dStarEff; /* Fraction of gas mass converted into
35 star mass per timestep. */
36 double dInitStarMass; /* Fixed Initial Star Mass */
37 double dMinSpawnStarMass; /* Minimum Initial Star Mass */
38 double dMaxStarMass; /* maximum mass star particle to form */
39 int bGasCooling; /* Can we call cooling for temperature */
40#ifdef COOLING_MOLECULARH
41 double dStarFormEfficiencyH2; /*Multiplier of H2 when calculating star formation */
42#ifdef SHIELDSF
43 double dSigmad; /* Dust optical depth coefficient */
44 double dMinMetalShield; /* Metallicity floor for dust shielding */
45#endif
46#endif
47 int bBHForm; /* Form Black Holes */
48 double dBHFormProb; /* Probability of Black Hole forming */
49 double dInitBHMass; /* Initial mass of Black Holes */
50 public:
51 int bUseStoch; /* use stochastic IMF */
52 double dStochCut; /* cutoff mass for stochastic IMF */
53 int iStarFormRung; /* rung for star formation */
54 double dMinGasMass; /* minimum mass gas before we delete
55 the particle. */
56 double dDeltaStarForm; /* timestep in system units */
57 };
58
61class Stfm : public Stfm_Shallow {
62private:
63 Stfm& operator=(const Stfm& st); /* private to prevent use */
64public:
65 IMF *imf;
66 void AddParams(PRM prm);
67 void CheckParams(PRM prm, struct parameters &param);
68 void NullStarForm() { imf = new Kroupa01(); } /* Place holder */
69 bool isStarFormRung(int aRung) {return aRung <= iStarFormRung;}
70 GravityParticle *FormStar(GravityParticle *p, COOL *Cool, double dTime,
71 double dDelta, double dCosmoFac, double *T,
72 double *H2Fraction, LWDATA *LWData, Rand& rndGen);
73
74 Stfm() {};
75 Stfm(const Stfm& st);
76 ~Stfm() {
77 delete imf;
78 };
79 inline void pup(PUP::er &p);
80};
81
82// "Deep copy" constructer is needed because of imf pointer
83inline Stfm::Stfm(const Stfm& st) : Stfm_Shallow(st) {
84 imf = st.imf->clone();
85}
86
87inline void Stfm::pup(PUP::er &p) {
88 p|dGmUnit;
89 p|dMsolUnit;
90 p|dGmPerCcUnit;
91 p|dSecUnit;
92 p|dErgUnit;
93 p|dPhysDenMin;
94 p|dOverDenMin;
95 p|dTempMax;
96 p|dSoftMin;
97 p|dCStar;
98 p|dStarEff;
99 p|dInitStarMass;
100 p|dMinSpawnStarMass;
101 p|dMaxStarMass;
102 p|bGasCooling;
103#ifdef COOLING_MOLECULARH
104 p|dStarFormEfficiencyH2;
105#ifdef SHIELDSF
106 p|dSigmad;
107 p|dMinMetalShield;
108#endif
109#endif
110 p|bBHForm;
111 p|dBHFormProb;
112 p|dInitBHMass;
113 p|bUseStoch;
114 p|dStochCut;
115 p|iStarFormRung;
116 p|dMinGasMass;
117 p|dDeltaStarForm;
118 p|imf;
119 }
120
122class StarLogEvent
123{
124 public:
125 int64_t iOrdStar;
126 int64_t iOrdGas;
127 double timeForm;
128 Vector3D<double> rForm;
129 Vector3D<double> vForm;
130 double massForm;
131 double rhoForm;
132 double TForm;
133#ifdef COOLING_MOLECULARH
134 double H2FracForm;
135#endif
136#ifdef COOLING_MOLECULARH
137 StarLogEvent() : iOrdGas(-1), timeForm(0),rForm(0),vForm(0),
138 massForm(0),rhoForm(0),TForm(0),H2FracForm(0){}
139 StarLogEvent(GravityParticle *p, double dCosmoFac, double TempForm, double H2FractionForm) {
140#else
141 StarLogEvent() : iOrdGas(-1), timeForm(0),rForm(0),vForm(0),
142 massForm(0),rhoForm(0),TForm(0){}
143 StarLogEvent(GravityParticle *p, double dCosmoFac, double TempForm) {
144#endif
145 iOrdGas = p->iOrder;
146 // star's iOrder assigned in TreePiece::NewOrder
147 timeForm = p->fTimeForm();
148 rForm = p->position;
149 vForm = p->velocity;
150 massForm = p->fMassForm();
151 rhoForm = p->fDensity/dCosmoFac;
152 TForm = TempForm;
153#ifdef COOLING_MOLECULARH
154 H2FracForm = H2FractionForm;
155#endif
156 }
157 void pup(PUP::er& p) {
158 p | iOrdStar;
159 p | iOrdGas;
160 p | timeForm;
161 p | rForm;
162 p | vForm;
163 p | massForm;
164 p | rhoForm;
165 p | TForm;
166#ifdef COOLING_MOLECULARH
167 p | H2FracForm;
168#endif
169 }
170 };
171
173class HMStarLogEvent
174{
175public:
176 int64_t iOrdStar;
177 double HMStars[ARRLENGTH];
178HMStarLogEvent() : iOrdStar(0) {
179 for(int i=0; i<ARRLENGTH; i++) HMStars[i]=0.0;
180 }
181HMStarLogEvent(GravityParticle *p) {
182 // star's iOrder assigned in TreePiece::NewOrder
183 for(int i=0; i<ARRLENGTH; i++) HMStars[i]=p->rgfHMStars(i);
184 }
185 void pup(PUP::er& p) {
186 p | iOrdStar;
187 PUParray(p,HMStars,ARRLENGTH);
188 }
189};
190
192class StarLog : public PUP::able
193{
194 public:
195 int nOrdered; /* The number of events that have been
196 globally ordered, incremented by
197 pkdNewOrder() */
198 std::string fileName;
199 std::vector<StarLogEvent> seTab; /* The actual table */
200 StarLog() : nOrdered(0),fileName("starlog") {}
201 void flush();
202 static void logMetaData(std::ofstream &ofsLog);
203 PUPable_decl(StarLog);
204 StarLog(CkMigrateMessage *m) : PUP::able(m) {}
205 void pup(PUP::er& p) {
206 PUP::able::pup(p);
207 p | nOrdered;
208 p | fileName;
209 p | seTab;
210 }
211 };
212
214class HMStarLog
215{
216public:
217 int nOrdered; /* The number of events that have been
218 globally ordered, incremented by
219 pkdNewOrder() */
220 std::string fileName;
221 std::vector<HMStarLogEvent> seTab; /* The actual table */
222 HMStarLog() : nOrdered(0),fileName("hmstarlog") {}
223 void flush();
224};
225
226#endif
Fundamental type for a particle.
Definition GravityParticle.h:364
int64_t iOrder
Input order of particles; unique particle ID.
Definition GravityParticle.h:403
Interface class for initial mass function.
Definition imf.h:21
virtual IMF * clone() const =0
copy IMF object
Implement IMF from Kroupa 2001.
Definition imf.h:149
basic random number generator This is implemented as an object so that it can easily be used in threa...
Definition rand.h:9
static void logMetaData(std::ofstream &ofsLog)
Print out metadata for the starlog.
Definition starform.cpp:690
void flush()
Flush starlog data to a file If the file format is changed remember to change logMetaData() below.
Definition starform.cpp:626
Parameters and methods to implement star formation.
Definition starform.h:19
Definition starform.h:61
void AddParams(PRM prm)
initialize parameters for star formation
Definition starform.cpp:20
Hold parameters of the run.
Definition parameters.h:15