@@ -264,11 +264,7 @@ class CoolRecipeCloudyAndPhotoHeating
264264 cool_component::PhotoelectricHeatingModel photoelectric_fn_;
265265
266266 public:
267- __host__ CoolRecipeCloudyAndPhotoHeating (ParameterMap &pmap,
268- cool_component::PhotoelectricHeatingModel photoelectric_fn)
269- : net_cloudy_(pmap), photoelectric_fn_{photoelectric_fn}
270- {
271- }
267+ __host__ CoolRecipeCloudyAndPhotoHeating (ParameterMap &pmap) : net_cloudy_(pmap), photoelectric_fn_(pmap) {}
272268
273269 __device__ Real cool_rate (Real n, Real T) const { return net_cloudy_ (n, T) - photoelectric_fn_ (n, T); }
274270};
@@ -311,9 +307,7 @@ class CoolRecipeTI
311307 }
312308
313309 public:
314- __host__ CoolRecipeTI (cool_component::PhotoelectricHeatingModel photoelectric_fn) : photoelectric_fn{photoelectric_fn}
315- {
316- }
310+ explicit __host__ CoolRecipeTI (ParameterMap &pmap) : photoelectric_fn(pmap) {}
317311
318312 __device__ Real cool_rate (Real n, Real T) { return cool_rate_only_ (n, T) - photoelectric_fn (n, T); }
319313};
@@ -323,34 +317,15 @@ std::function<void(Grid3D &)> configure_cooling_callback(std::string kind, Param
323317 // the caller of this function will is responsible for raising an error when:
324318 // - "chemistry.data_file" is set, but we aren't using a recipe that doesn't need a datafile
325319
326- // First, we configure an instance of PhotoelectricHeatingModel, based off the parameters
327- // -> to help provide informative error messages, we store the names of the parameters in variables
328- // -> maybe we should only use a single parameter, to just specify the value of n_av_cgs?
329- const char *use_photoelectric_parname = " chemistry.photoelectric_heating" ;
330- const char *photoelectric_n_av_parname = " chemistry.photoelectric_n_av_cgs" ;
331-
332- cool_component::PhotoelectricHeatingModel photoelectric_fn;
333- if (pmap.value_or (use_photoelectric_parname, false )) {
334- // In this case, we want to actually use photoelectric heating
335- double n_av_cgs = pmap.value_or (photoelectric_n_av_parname, 100.0 );
336- CHOLLA_ASSERT (n_av_cgs > 0.0 , " The \" %s\" parameter cannot specify a non-positive value" ,
337- photoelectric_n_av_parname);
338- photoelectric_fn = cool_component::PhotoelectricHeatingModel{n_av_cgs};
339- } else {
340- CHOLLA_ASSERT (!pmap.has_param (photoelectric_n_av_parname),
341- " It is an error to specify the \" %s\" parameter when the \" %s\" hasn't "
342- " explicitly been set to true." ,
343- photoelectric_n_av_parname, use_photoelectric_parname);
344- photoelectric_fn = cool_component::PhotoelectricHeatingModel{0.0 }; // this means that there isn't heating
345- }
320+ bool use_photoelectric_heating = cool_component::PhotoelectricHeatingModel::is_specified_by_params (pmap);
346321
347322 // Next, we branch based on the cooling-recipe
348323 if (kind == " tabulated-cloudy" ) {
349324 // since photoelectric_fn can be configured to be inactive, we could probably just
350325 // consolidate the definitions of CoolRecipeCloudyAndPhotoHeating and CoolRecipeCloudy
351326
352- if (photoelectric_fn. is_active () ) {
353- CoolRecipeCloudyAndPhotoHeating recipe (pmap, photoelectric_fn );
327+ if (use_photoelectric_heating ) {
328+ CoolRecipeCloudyAndPhotoHeating recipe (pmap);
354329 CoolingUpdateExecutor<CoolRecipeCloudyAndPhotoHeating> updater (recipe);
355330 return {updater};
356331 } else {
@@ -359,13 +334,13 @@ std::function<void(Grid3D &)> configure_cooling_callback(std::string kind, Param
359334 return {updater};
360335 }
361336 } else if (kind == " piecewise-cie" ) {
362- CHOLLA_ASSERT (not photoelectric_fn. is_active () ,
337+ CHOLLA_ASSERT (not use_photoelectric_heating ,
363338 " The \" %s\" cooling recipe is **NOT** compatible with photoelectric heating" , kind.c_str ());
364339 CoolRecipeCIE recipe{};
365340 CoolingUpdateExecutor<CoolRecipeCIE> updater (recipe);
366341 return {updater};
367342 } else if (kind == " piecewise-ti" ) {
368- CoolRecipeTI recipe{photoelectric_fn} ;
343+ CoolRecipeTI recipe (pmap) ;
369344 CoolingUpdateExecutor<CoolRecipeTI> updater (recipe);
370345 return {updater};
371346 }
0 commit comments