[docs]defthomas_fermi_pressure(self,n_e_m3,T_eV):""" Hardened Thomas-Fermi Equation of State (EOS) heuristic. Accounts for electron degeneracy pressure in the WDM regime. P_total = P_ideal + P_deg """p_ideal=n_e_m3*(T_eV*1.602e-19)# Boltzmannh_bar=1.054e-34m_e=9.109e-31p_deg=(h_bar**2/m_e)*(n_e_m3**(5.0/3.0))# Fermi degeneracyreturnp_ideal+p_deg
[docs]defcalculate_redeposition_fraction(self,T_edge_eV,B_field_T):""" Estimates the fraction of sputtered atoms that are promptly redeposited. Redeposition fraction f_redep ~ 1 - (lambda_ion / rho_L) For heavy impurities (W) in high B-field, redeposition can exceed 90%. """# Ionization mean free path lambda_ion ~ v_thermal / (n_e * <sigma_v>_ion)# Larmor radius rho_L = m*v / qB# Heuristic for W: f_redep increases with density and B-fieldn_e_edge=self.transport.ne[-1]*1e19# Scaling based on impurity transport benchmarksf_redep=0.95*(1.0-np.exp(-(B_field_T/5.0)*(n_e_edge/1e19)))returnfloat(np.clip(f_redep,0.0,0.99))
[docs]defplot_results(self,history):df=pd.DataFrame(history)fig,(ax1,ax2)=plt.subplots(2,1,figsize=(10,8))ax1.plot(df["time"],df["Te_core"],"r-",label="Core Temp (keV)")ax1.set_ylabel("Temperature")ax1.set_title("Thermal Quench due to Impurity Accumulation")ax1.grid(True)ax1.legend()ax2.plot(df["time"],df["W_impurity"],"k-",label="Total Impurities")ax2.set_xlabel("Time (s)")ax2.set_ylabel("Accumulation (a.u.)")ax2.legend()plt.tight_layout()plt.savefig("WDM_Simulation_Result.png")print("Analysis Saved: WDM_Simulation_Result.png")
if__name__=="__main__":cfg="03_CODE/SCPN-Fusion-Core/validation/iter_validated_config.json"wdm=WholeDeviceModel(cfg)wdm.run_discharge(duration_sec=2.0)# Short run to see collapse