@@ -194,14 +194,15 @@ def write_opacity_cmd(
194194 output_path ,
195195 stars ,
196196 n_dust ,
197- dust_components ,
198- dust_size_min ,
199- dust_size_max ,
200- dust_size_powerlaw = - 3.5 ,
201- mean_molecular_weight = 2.37 ,
202- mass_fraction = 1 ,
203- nr_threads = 8 ,
204- output_num = 0 ,
197+ # dust_components,
198+ # dust_size_min,
199+ # dust_size_max,
200+ # dust_size_powerlaw = -3.5,
201+ dust_mixtures ,
202+ mean_molecular_weight = 2.37 ,
203+ mass_fraction = 1 ,
204+ nr_threads = 1 ,
205+ output_num = 0 ,
205206):
206207 """
207208 Write a POLARIS command file for the opacity-only run.
@@ -245,23 +246,40 @@ def write_opacity_cmd(
245246 cmd_path .parent .mkdir (parents = True , exist_ok = True )
246247
247248 # Log-spaced size bin edges
248- size_edges = np .logspace (np .log10 (dust_size_min ),
249- np .log10 (dust_size_max ), n_dust + 1 )
249+ # size_edges = np.logspace(np.log10(dust_size_min),
250+ # np.log10(dust_size_max), n_dust + 1)
250251
251252 print (f"Writing POLARIS opacity command file: { cmd_path } " )
252253
253254 with open (cmd_path , "w" ) as f :
254255 # --- <common> block ---
255256 f .write ("<common>\n " )
256257
257- for i in range (n_dust ):
258- for comp in dust_components :
258+ # for i in range(n_dust):
259+ # for comp in dust_components:
260+ # f.write(
261+ # f'\n\t<dust_component id = "{i}"> '
262+ # f'"{comp["path"]}" "plaw" {comp["weight"]} 0 '
263+ # f'{size_edges[i]:.2e} {size_edges[i+1]:.2e} '
264+ # f'{dust_size_powerlaw}'
265+ # )
266+
267+ for mixture , components in dust_mixtures .items ():
268+ for component in components .values ():
259269 f .write (
260- f'\n \t <dust_component id = "{ i } "> '
261- f'"{ comp ["path" ]} " "plaw" { comp ["weight" ]} 0 '
262- f'{ size_edges [i ]:.2e} { size_edges [i + 1 ]:.2e} '
263- f'{ dust_size_powerlaw } '
270+ f'\n \t <dust_component id = "{ mixture } "> '
271+ f'"{ component ["path" ]} " '
272+ f'"{ component ["distribution" ]} " '
273+ f'{ component ["fraction" ]} '
274+ f'{ component ["density" ]} '
275+ f'{ component ["amin" ]:.2e} '
276+ f'{ component ["amax" ]:.2e} '
264277 )
278+ index = component ['index' ] if isinstance (component ['index' ], list ) else [component ['index' ]]
279+ for i in index :
280+ f .write (
281+ f' { i } '
282+ )
265283
266284 f .write (f"\n \n \t <nr_threads> { nr_threads } \n " )
267285 f .write ("\n </common>\n " )
@@ -359,17 +377,18 @@ def run_opacity(
359377 ramses_dir ,
360378 polaris_dir ,
361379 grid_path ,
362- dust_components ,
363- dust_size_min ,
364- dust_size_max ,
365- dust_size_powerlaw = - 3.5 ,
366- mean_molecular_weight = 2.37 ,
367- mass_fraction = 0.01 ,
368- nr_threads = 8 ,
369- f_acc = 0.1 ,
370- n_dust_override = None ,
371- polaris_binary = "polaris" ,
372- cleanup = True ,
380+ # dust_components,
381+ # dust_size_min,
382+ # dust_size_max,
383+ # dust_size_powerlaw = -3.5,
384+ dust_mixtures ,
385+ mean_molecular_weight = 2.37 ,
386+ mass_fraction = 0.01 ,
387+ nr_threads = 1 ,
388+ f_acc = 0.1 ,
389+ n_dust_override = None ,
390+ polaris_binary = "polaris" ,
391+ cleanup = True ,
373392):
374393 """
375394 Full Step 4: derive stellar properties, write the POLARIS command file,
@@ -440,19 +459,20 @@ def run_opacity(
440459 cmd_path = polaris_dir / cmd_filename
441460
442461 write_opacity_cmd (
443- cmd_path = cmd_path ,
444- grid_path = grid_path ,
445- output_path = polaris_dir ,
446- stars = stars ,
447- n_dust = n_dust ,
448- dust_components = dust_components ,
449- dust_size_min = dust_size_min ,
450- dust_size_max = dust_size_max ,
451- dust_size_powerlaw = dust_size_powerlaw ,
452- mean_molecular_weight = mean_molecular_weight ,
453- mass_fraction = mass_fraction ,
454- nr_threads = nr_threads ,
455- output_num = output_num ,
462+ cmd_path = cmd_path ,
463+ grid_path = grid_path ,
464+ output_path = polaris_dir ,
465+ stars = stars ,
466+ n_dust = n_dust ,
467+ # dust_components = dust_components,
468+ # dust_size_min = dust_size_min,
469+ # dust_size_max = dust_size_max,
470+ # dust_size_powerlaw = dust_size_powerlaw,
471+ dust_mixtures = dust_mixtures ,
472+ mean_molecular_weight = mean_molecular_weight ,
473+ mass_fraction = mass_fraction ,
474+ nr_threads = nr_threads ,
475+ output_num = output_num
456476 )
457477
458478 # 5) Cleanup previous run
0 commit comments