changa 3.5
Loading...
Searching...
No Matches
feedback.h
1#ifndef FEEDBACK_HINCLUDED
2#define FEEDBACK_HINCLUDED
3
4#include "parameters.h"
5#include "supernova.h"
6#include "imf.h"
7#include "starlifetime.h"
8#include "rand.h"
9#include "lymanwerner.h"
10#define NFEEDBACKS 5
11
15class FBEffects {
16 public:
17 double dEnergy; /* Energy produced per mass (ergs/gm); note that
18 this might need to be divided up
19 into different forms of energy. */
20 double dMassLoss; /* Mass lost in Solar Masses */
21 double dMetals; /* Fraction of the mass lost in
22 elements heavier than Helium */
23 double dMIron; /* Solar masses of iron ejected */
24 double dMOxygen; /* Solar masses of oxygen ejected */
25 FBEffects() : dEnergy(0), dMassLoss(0), dMetals(0), dMIron(0), dMOxygen(0) { }
26 FBEffects(double dEnergy, double dMassLoss, double dMetals, double dMIron, double dMOxygen) :
27 dEnergy(dEnergy), dMassLoss(dMassLoss), dMetals(dMetals), dMIron(dMIron), dMOxygen(dMOxygen) { }
28 };
29
34class SFEvent {
35 public:
36 double dMass; /* mass in star formation event in solar masses */
37 double dTimeForm; /* time of star formation event in years */
38 double dMetals; /* metallicity of stars in event */
39 double dMFracOxygen; /* metallicity of stars in event */
40 double dMFracIron; /* metallicity of stars in event */
41 double dLowNorm; /* normalization constant for low mass IMF */
42#ifdef STOCH24
43 double rgdHMStars[24]; /* high mass stars in stochastic IMF */
44 SFEvent(double mass, double tform, double mets, double fefrac, double oxfrac, double lownorm, double *hmstars) :
45 dMass(mass), dTimeForm(tform), dMetals(mets), dMFracIron(fefrac), dMFracOxygen(oxfrac), dLowNorm(lownorm) {
46 for(int i=0;i<24;i++) rgdHMStars[i]=hmstars[i];
47 }
48#else
49 double rgdHMStars[12]; /* high mass stars in stochastic IMF */
50 SFEvent(double mass, double tform, double mets, double fefrac, double oxfrac, double lownorm, double *hmstars) :
51 dMass(mass), dTimeForm(tform), dMetals(mets), dMFracIron(fefrac), dMFracOxygen(oxfrac), dLowNorm(lownorm) {
52 for(int i=0;i<12;i++) rgdHMStars[i]=hmstars[i];
53 }
54#endif
55
56 SFEvent() : dMass(0), dTimeForm(0), dMetals(0), dMFracIron(0), dMFracOxygen(0) { }
57 SFEvent(double mass, double tform, double mets, double fefrac, double oxfrac) :
58 dMass(mass), dTimeForm(tform), dMetals(mets), dMFracIron(fefrac), dMFracOxygen(oxfrac) { }
59 };
60
63 protected:
64 double dGmUnit; /* system mass in grams */
65 double dGmPerCcUnit; /* system density in gm/cc */
66 double dErgUnit; /* system energy in ergs */
67 Padova pdva;
68 public:
69 char achIMF[32]; /* initial mass function */
70 mutable SN sn;
71 double dDeltaStarForm;
72 double dErgPerGmUnit; /* system specific energy in ergs/gm */
73 double dSecUnit; /* system time in seconds */
74 double dMaxGasMass; /* Maximum mass of a gas particle */
75#ifdef SPLITGAS
76 double dInitGasMass; /* Original mass of a gas particle */
77#endif
78 int bSNTurnOffCooling; /* turn off cooling or not */
79 int bSmallSNSmooth; /* smooth SN energy only over blast radius */
80 int bShortCoolShutoff; /* use snowplow time */
81 int bAGORAFeedback; /* Replace stellar feedback with AGORA perscription */
82 double dExtraCoolShutoff; /* multiplicative factor for shutoff time */
83 double dRadPreFactor; /* McKee + Ostriker size constant in system units */
84 double dTimePreFactor; /* McKee + Ostriker time constant in system units */
85 int nSmoothFeedback; /* number of particles to smooth feedback over*/
86 double dMaxCoolShutoff; /* Maximum length of time to shutoff cooling */
87 double dEarlyFeedbackFrac; /* Fraction of SNe II to put in early feedback */
88 double dFBInitialMassLoad; /* Initial Mass Loading in Superbubble feedback*/
89 double dMultiPhaseMinTemp;
90 double dMultiPhaseMaxTime;
91 double dEarlyETotal; /* Total E in early FB per solar mass of stars */
92 };
93
96class Fdbk : public Fdbk_Shallow {
97private:
98 Fdbk& operator=(const Fdbk& fb); /* private to prevent use */
99 void CalcWindFeedback(SFEvent *sfEvent, double dTime,
100 double dDelta, FBEffects *fbEffects) const;
101 void CalcUVFeedback(SFEvent *sfEvent, double dTime, double dDelta,
102 FBEffects *fbEffects) const;
103#ifdef COOLING_MOLECULARH
104 double CalcLWFeedback(SFEvent *sfEvent, double dTime, double dDelta, LWDATA *LWData) const;
105#endif /*COOLING_MOLECULARH*/
106
107public:
108 IMF *imf;
109 void AddParams(PRM prm);
110 void CheckParams(PRM prm, struct parameters &param);
111 void NullFeedback() { imf = new Kroupa01(); } /* Place holder */
112 void DoFeedback(GravityParticle *p, double dTime, double dDeltaYr,
113 FBEffects *fbTotals, LWDATA *LWData, Rand& rndGen) const;
114 double NSNIa (double dMassT1, double dMassT2);
115
116 Fdbk() { }
117 Fdbk(const Fdbk& fb);
118 ~Fdbk() {
119 delete imf;
120 }
121 inline void pup(PUP::er &p);
122};
123
124// "Deep copy" constructer is need because of imf pointer.
125inline Fdbk::Fdbk(const Fdbk& fb) : Fdbk_Shallow(fb) {
126 imf = fb.imf->clone();
127}
128
129inline void Fdbk::pup(PUP::er &p) {
130 p | dGmUnit;
131 p | dGmPerCcUnit;
132 p | dErgUnit;
133 p | pdva;
134 p(achIMF, 32);
135 p | sn;
136 p | dDeltaStarForm;
137 p | dErgPerGmUnit;
138 p | dSecUnit;
139 p | dMaxGasMass;
140#ifdef SPLITGAS
141 p | dInitGasMass;
142#endif
143 p | bSNTurnOffCooling;
144 p | bSmallSNSmooth;
145 p | bShortCoolShutoff;
146 p | bAGORAFeedback;
147 p | dExtraCoolShutoff;
148 p | dRadPreFactor;
149 p | dTimePreFactor;
150 p | nSmoothFeedback;
151 p | dMaxCoolShutoff;
152 p | dEarlyFeedbackFrac;
153 p | dFBInitialMassLoad;
154 p | dMultiPhaseMinTemp;
155 p | dMultiPhaseMaxTime;
156 p | dEarlyETotal;
157 p | imf;
158 }
159
160enum FBenum{
161 FB_SNII=0,
162 FB_SNIA,
163 FB_WIND,
164 FB_UV,
165 FB_AGORA
166};
167
168#include "smoothparams.h"
169
174
175class AGORApreCheckSmoothParams : public SmoothParams
176{
177 double dTime, dDelta, H, a, gamma, etaCourant, timeToSF, dMsolUnit, dErgPerGmUnit;
178 Fdbk fb;
179 virtual void fcnSmooth(GravityParticle *p, int nSmooth,
180 pqSmoothNode *nList);
181 virtual int isSmoothActive(GravityParticle *p) { return p->isStar(); }
182 virtual void initSmoothParticle(GravityParticle *p) {}
183 virtual void initTreeParticle(GravityParticle *p) {}
184 virtual void postTreeParticle(GravityParticle *p) {}
185 virtual void initSmoothCache(GravityParticle *p);
186 virtual void combSmoothCache(GravityParticle *p1,
188 void DistFBMME(GravityParticle *p, int nSmooth, pqSmoothNode *nList);
189 public:
190 AGORApreCheckSmoothParams() {}
191 AGORApreCheckSmoothParams(int _iType, int am, CSM csm, double _dTime, double _dDelta,
192 double _gamma, double _etaCourant, double _timeToSF, Fdbk *feedback,
193 double _dMsolUnit, double _dErgPerGmUnit) :
194 fb (*feedback) {
195 iType = _iType;
196 activeRung = am;
197 bUseBallMax = 0;
198 gamma = _gamma;
199 etaCourant = _etaCourant;
200 timeToSF = _timeToSF;
201 dMsolUnit = _dMsolUnit;
202 dErgPerGmUnit = _dErgPerGmUnit;
203 dTime = _dTime;
204 dDelta = _dDelta;
205 if(csm->bComove) {
206 H = csmTime2Hub(csm,dTime);
207 a = csmTime2Exp(csm,dTime);
208 }
209 else {
210 H = 0.0;
211 a = 1.0;
212 }
213 }
214 PUPable_decl(AGORApreCheckSmoothParams);
215 AGORApreCheckSmoothParams(CkMigrateMessage *m) : SmoothParams(m) {}
216 virtual void pup(PUP::er &p) {
218 p|a;
219 p|H;
220 p|gamma;
221 p|etaCourant;
222 p|timeToSF;
223 p|dMsolUnit;
224 p|dErgPerGmUnit;
225 p|fb;
226 p|dTime;
227 p|dDelta;
228 }
229 };
230
235
236class DistStellarFeedbackSmoothParams : public SmoothParams
237{
238 double dTime, H, a, gamma;
239 Fdbk fb;
240 virtual void fcnSmooth(GravityParticle *p, int nSmooth,
241 pqSmoothNode *nList);
242 virtual int isSmoothActive(GravityParticle *p);
243 virtual void initSmoothParticle(GravityParticle *p) {}
244 virtual void initTreeParticle(GravityParticle *p);
245 virtual void postTreeParticle(GravityParticle *p);
246 virtual void initSmoothCache(GravityParticle *p);
247 virtual void combSmoothCache(GravityParticle *p1,
249 void DistFBMME(GravityParticle *p, int nSmooth, pqSmoothNode *nList);
250 public:
251 DistStellarFeedbackSmoothParams() {}
252 DistStellarFeedbackSmoothParams(int _iType, int am, CSM csm, double _dTime,
253 double _gamma, Fdbk *feedback) :
254 fb (*feedback) {
255 iType = _iType;
256 activeRung = am;
257 bUseBallMax = 0;
258 gamma = _gamma;
259 dTime = _dTime;
260 if(csm->bComove) {
261 H = csmTime2Hub(csm,dTime);
262 a = csmTime2Exp(csm,dTime);
263 }
264 else {
265 H = 0.0;
266 a = 1.0;
267 }
268 }
269 /*~DistStellarFeedbackSmoothParams() {
270 delete fb;
271 }*/
272 PUPable_decl(DistStellarFeedbackSmoothParams);
273 DistStellarFeedbackSmoothParams(CkMigrateMessage *m) : SmoothParams(m) {}
274 virtual void pup(PUP::er &p) {
275 SmoothParams::pup(p);//Call base class
276 p|a;
277 p|H;
278 p|gamma;
279 p|fb;
280 p|dTime;
281 }
282 };
283
284#endif
285
virtual void pup(PUP::er &p)
required method for remote entry call.
Definition feedback.h:216
virtual void pup(PUP::er &p)
required method for remote entry call.
Definition feedback.h:274
Class for cross processor data needed for smooth operations.
Definition GravityParticle.h:649
Class to return feedback effects.
Definition feedback.h:15
Stellar/Supernova feedback parameters and routines.
Definition feedback.h:62
Definition feedback.h:96
void DoFeedback(GravityParticle *p, double dTime, double dDeltaYr, FBEffects *fbTotals, LWDATA *LWData, Rand &rndGen) const
Fdbk main method.
Definition feedback.cpp:447
void AddParams(PRM prm)
initialize parameters for star formation
Definition feedback.cpp:25
void CheckParams(PRM prm, struct parameters &param)
Definition feedback.cpp:107
Fundamental type for a particle.
Definition GravityParticle.h:364
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
routines to calculate stellar lifetimes as a function of mass and metalicity.
Definition starlifetime.h:27
basic random number generator This is implemented as an object so that it can easily be used in threa...
Definition rand.h:9
Definition feedback.h:34
Methods for calculating the number and feedback effects of supernova.
Definition supernova.h:13
int iType
Particle type to smooth over; "TreeActive".
Definition smoothparams.h:11
virtual void pup(PUP::er &p)
required method for remote entry call.
Definition smoothparams.h:45
int activeRung
Currently active rung.
Definition smoothparams.h:12
int bUseBallMax
Definition smoothparams.h:14
Object for priority queue entry.
Definition smooth.h:13
Hold parameters of the run.
Definition parameters.h:15