def inner(): atmos = Atmosphere(ScaleType.Geometric, depthScale=atmosData['height'], temperature=atmosData['temp'], vlos=atmosData['vlos'], vturb=4000 * np.ones_like(atmosData['height'])) aSet = RadiativeSet([ H_3_atom(), C_atom(), O_atom(), Si_atom(), Al_atom(), CaII_atom(), Fe_atom(), He_atom(), MgII_atom(), N_atom(), Na_atom(), S_atom() ]) aSet.set_active('Ca') spect = aSet.compute_wavelength_grid() atmos.convert_scales(Pgas=atmosData['pgas']) atmos.quadrature(5) mols = MolecularTable() eqPops = aSet.iterate_lte_ne_eq_pops(mols, atmos) ctx = LwContext(atmos, spect, eqPops, conserveCharge=False) iterate_ctx(ctx, prd=False) eqPops.update_lte_atoms_Hmin_pops(atmos) Iwave = ctx.compute_rays(wave, [1.0]) return Iwave
def cmo_synth(atmosData, crsw=None): with open(os.devnull, 'w') as f: with redirect_stdout(f): if crsw is not None: crsw = crsw() atmos = Atmosphere(ScaleType.Geometric, depthScale=atmosData['height'], temperature=atmosData['temp'], vlos=atmosData['vlos'], vturb=4000 * np.ones_like(atmosData['height'])) aSet = RadiativeSet([ H_3_atom(), C_atom(), O_atom(), Si_atom(), Al_atom(), CaII_atom(), Fe_atom(), He_atom(), MgII_atom(), N_atom(), Na_atom(), S_atom() ]) aSet.set_active('H', 'Ca') spect = aSet.compute_wavelength_grid() atmos.convert_scales(Pgas=atmosData['pgas']) atmos.quadrature(5) mols = MolecularTable() eqPops = aSet.iterate_lte_ne_eq_pops(mols, atmos) ctx = LwContext(atmos, spect, eqPops, conserveCharge=True, initSol=InitialSolution.Lte, crswCallback=crsw) iterate_ctx(ctx, prd=False) eqPops.update_lte_atoms_Hmin_pops(atmos) Iwave = ctx.compute_rays(wave, [1.0]) return Iwave
def cmo_synth_given(atmosData): with open(os.devnull, 'w') as f: with redirect_stdout(f): at = get_global_atomic_table() atmos = Atmosphere(ScaleType.Geometric, depthScale=atmosData['height'], temperature=atmosData['temp'], vlos=atmosData['vlos'], vturb=4000 * np.ones_like(atmosData['height']), ne=atmosData['ne'], nHTot=(atmosData['density'] / (at.weightPerH * Const.Amu))) aSet = RadiativeSet([ H_3_atom(), C_atom(), O_atom(), Si_atom(), Al_atom(), CaII_atom(), Fe_atom(), He_atom(), MgII_atom(), N_atom(), Na_atom(), S_atom() ]) aSet.set_active('Ca') spect = aSet.compute_wavelength_grid() atmos.convert_scales() atmos.quadrature(5) mols = MolecularTable() eqPops = aSet.iterate_lte_ne_eq_pops(mols, atmos) ctx = LwContext(atmos, spect, eqPops, conserveCharge=False) iterate_ctx(ctx, prd=False) Iwave = ctx.compute_rays(wave, [1.0]) return Iwave
def cmo_synth(atmosData, crsw=None, NmaxIter=1000): with open(os.devnull, 'w') as f: with redirect_stdout(f): if crsw is not None: crsw = crsw() atmos = Atmosphere(ScaleType.Geometric, depthScale=atmosData['height'], temperature=atmosData['temp'], vlos=atmosData['vlos'], vturb=4000 * np.ones_like(atmosData['height'])) aSet = RadiativeSet([ H_3_atom(), C_atom(), O_atom(), Si_atom(), Al_atom(), CaII_atom(), Fe_atom(), He_atom(), MgII_atom(), N_atom(), Na_atom(), S_atom() ]) aSet.set_active('H', 'Ca') spect = aSet.compute_wavelength_grid() atmos.convert_scales(Pgas=atmosData['pgas']) atmos.quadrature(5) mols = MolecularTable() eqPops = aSet.iterate_lte_ne_eq_pops(mols, atmos) ctx = LwContext(atmos, spect, eqPops, conserveCharge=True, initSol=InitialSolution.Lte, crswCallback=crsw) converged = True exploding = False try: nIter = iterate_ctx(ctx, prd=False, NmaxIter=NmaxIter) except ConvergenceError: converged = False nIter = NmaxIter except ExplodingMatrixError: converged = False exploding = True nIter = NmaxIter if converged: eqPops.update_lte_atoms_Hmin_pops(atmos) IwaveCa = ctx.compute_rays(waveCa, [1.0]) IwaveHa = ctx.compute_rays(waveHa, [1.0]) return { 'IwaveCa': IwaveCa, 'IwaveHa': IwaveHa, 'eqPops': eqPops, 'converged': converged, 'nIter': nIter, 'atmosData': atmosData, 'exploding': exploding } else: return { 'converged': converged, 'nIter': nIter, 'atmosData': atmosData, 'exploding': exploding }
Si_atom(), Al_atom(), CaII_atom(), Fe_atom(), He_atom(), MgII_atom(), N_atom(), Na_atom(), S_atom() ]) aSet.set_active('H') spect = aSet.compute_wavelength_grid() # molPaths = [get_default_molecule_path() + m + '.molecule' for m in ['H2']] molPaths = [] mols = MolecularTable(molPaths) eqPops = aSet.compute_eq_pops(atmos, mols=mols) ctx = LwContext(atmos, spect, eqPops, ngOptions=NgOptions(0, 0, 0), hprd=Prd, conserveCharge=False) iterate_ctx(ctx, prd=Prd) print('Achieved initial Stat Eq') print('Waiting') input() dt = 0.5