changa  3.5
 All Classes Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
starform.h
Go to the documentation of this file.
1 
4 #ifndef STARFORM_HINCLUDED
5 #define STARFORM_HINCLUDED
6 
7 #include "parameters.h"
8 
10 class Stfm {
11  private:
12  double dGmUnit; /* system mass in grams */
13  double dGmPerCcUnit; /* system density in gm/cc */
14  double dSecUnit; /* system time in seconds */
15  double dErgUnit; /* system energy in ergs */
16  double dPhysDenMin; /* Physical density minimum for star
17  formation (in system units) */
18  double dOverDenMin; /* Overdensity minimum for star formation */
19  double dTempMax; /* Form stars below this temperature
20  EVEN IF the gas is not cooling. */
21  double dSoftMin; /* Jean's length as a fraction of
22  softening at which to form stars*/
23  double dCStar; /* Star formation constant */
24  double dStarEff; /* Fraction of gas mass converted into
25  star mass per timestep. */
26  double dInitStarMass; /* Fixed Initial Star Mass */
27  double dMinSpawnStarMass; /* Minimum Initial Star Mass */
28  double dMaxStarMass; /* maximum mass star particle to form */
29  int bGasCooling; /* Can we call cooling for temperature */
30 #ifdef COOLING_MOLECULARH
31  double dStarFormEfficiencyH2; /*Multiplier of H2 when calculating star formation */
32 #endif
33  int bBHForm; /* Form Black Holes */
34  double dBHFormProb; /* Probability of Black Hole forming */
35  double dInitBHMass; /* Initial mass of Black Holes */
36  public:
37  int iStarFormRung; /* rung for star formation */
38  int iRandomSeed; /* seed for probability */
39  double dMinGasMass; /* minimum mass gas before we delete
40  the particle. */
41  double dDeltaStarForm; /* timestep in system units */
42  void AddParams(PRM prm);
43  void CheckParams(PRM prm, struct parameters &param);
44  bool isStarFormRung(int aRung) {return aRung <= iStarFormRung;}
45  GravityParticle *FormStar(GravityParticle *p, COOL *Cool, double dTime,
46  double dDelta, double dCosmoFac, double *T, double *H2Fraction);
47  inline void pup(PUP::er &p);
48  };
49 
50 inline void Stfm::pup(PUP::er &p) {
51  p|dDeltaStarForm;
52  p|iStarFormRung;
53  p|iRandomSeed;
54  p|dGmUnit;
55  p|dGmPerCcUnit;
56  p|dSecUnit;
57  p|dErgUnit;
58  p|dPhysDenMin;
59  p|dOverDenMin;
60  p|dTempMax;
61  p|dSoftMin;
62  p|dCStar;
63  p|dStarEff;
64  p|dInitStarMass;
65  p|dMinSpawnStarMass;
66  p|dMinGasMass;
67  p|dMaxStarMass;
68  p|bGasCooling;
69 #ifdef COOLING_MOLECULARH
70  p|dStarFormEfficiencyH2;
71 #endif
72  p|bBHForm;
73  p|dBHFormProb;
74  p|dInitBHMass;
75  }
76 
79 {
80  public:
81  int64_t iOrdStar;
82  int64_t iOrdGas;
83  double timeForm;
84  Vector3D<double> rForm;
85  Vector3D<double> vForm;
86  double massForm;
87  double rhoForm;
88  double TForm;
89 #ifdef COOLING_MOLECULARH
90  double H2FracForm;
91 #endif
92 #ifdef COOLING_MOLECULARH
93  StarLogEvent() : iOrdGas(-1), timeForm(0),rForm(0),vForm(0),
94  massForm(0),rhoForm(0),TForm(0),H2FracForm(0){}
95  StarLogEvent(GravityParticle *p, double dCosmoFac, double TempForm, double H2FractionForm) {
96 #else
97  StarLogEvent() : iOrdGas(-1), timeForm(0),rForm(0),vForm(0),
98  massForm(0),rhoForm(0),TForm(0){}
99  StarLogEvent(GravityParticle *p, double dCosmoFac, double TempForm) {
100 #endif
101  iOrdGas = p->iOrder;
102  // star's iOrder assigned in TreePiece::NewOrder
103  timeForm = p->fTimeForm();
104  rForm = p->position;
105  vForm = p->velocity;
106  massForm = p->fMassForm();
107  rhoForm = p->fDensity/dCosmoFac;
108  TForm = TempForm;
109 #ifdef COOLING_MOLECULARH
110  H2FracForm = H2FractionForm;
111 #endif
112  }
113  void pup(PUP::er& p) {
114  p | iOrdStar;
115  p | iOrdGas;
116  p | timeForm;
117  p | rForm;
118  p | vForm;
119  p | massForm;
120  p | rhoForm;
121  p | TForm;
122 #ifdef COOLING_MOLECULARH
123  p | H2FracForm;
124 #endif
125  }
126  };
127 
129 class StarLog : public PUP::able
130 {
131  public:
132  int nOrdered; /* The number of events that have been
133  globally ordered, incremented by
134  pkdNewOrder() */
135  std::string fileName;
136  std::vector<StarLogEvent> seTab; /* The actual table */
137  StarLog() : nOrdered(0),fileName("starlog") {}
138  void flush();
139  static void logMetaData(std::ofstream &ofsLog);
140  PUPable_decl(StarLog);
141  StarLog(CkMigrateMessage *m) : PUP::able(m) {}
142  void pup(PUP::er& p) {
143  PUP::able::pup(p);
144  p | nOrdered;
145  p | fileName;
146  p | seTab;
147  }
148  };
149 
150 #endif
Parameters and methods to implement star formation.
Definition: starform.h:10
void AddParams(PRM prm)
initialize parameters for star formation
Definition: starform.cpp:20
Holds statistics of the star formation event.
Definition: starform.h:78
Hold parameters of the run.
Definition: parameters.h:14
int64_t iOrder
Input order of particles; unique particle ID.
Definition: GravityParticle.h:328
Object containing the parameter information.
Definition: param.h:38
Heating/Cooling context: parameters and tables.
Definition: cooling_boley.h:83
Fundamental type for a particle.
Definition: GravityParticle.h:316
Log of star formation events to be written out to a file.
Definition: starform.h:129