@@ -39,7 +39,7 @@ Setting up a simple afterglow model
3939 bands = np.array([1e9 , 1e14 , 1e17 ])
4040
4141 # Calculate the afterglow emission at each time and frequency
42- results = model.specific_flux_matrix (times, bands)
42+ results = model.specific_flux (times, bands)
4343
4444 # Visualize the multi-wavelength light curves
4545 plt.figure(figsize = (4.8 , 3.6 ),dpi = 200 )
@@ -48,7 +48,7 @@ Setting up a simple afterglow model
4848 for i, nu in enumerate (bands):
4949 exp = int (np.floor(np.log10(nu)))
5050 base = nu / 10 ** exp
51- plt.loglog(times, results[' syn' ][i,:], label = fr ' $ { base:.1f } \times 10^ {{ { exp} }} $ Hz ' )
51+ plt.loglog(times, results[' syn' ][i,:], label = fr ' $ { base:.1f } \times 10^ {{ { exp} }} $ Hz ' )
5252
5353 plt.xlabel(' Time (s)' )
5454 plt.ylabel(' Flux Density (erg/cm²/s/Hz)' )
@@ -61,7 +61,7 @@ Setting up a simple afterglow model
6161 epochs = np.array([1e2 , 1e3 , 1e4 , 1e5 ,1e6 , 1e7 , 1e8 ])
6262
6363 # Calculate spectra at each epoch
64- results = model.specific_flux_matrix (epochs, frequencies)
64+ results = model.specific_flux (epochs, frequencies)
6565
6666 # Plot broadband spectra at each epoch
6767 plt.figure(figsize = (4.8 , 3.6 ),dpi = 200 )
@@ -235,84 +235,85 @@ Those profiles are optional and will be set to zero function if not provided.
235235Radiation Processes
236236-------------------
237237
238- Synchrotron Self- Compton
238+ Inverse Compton Cooling
239239^^^^^^^^^^^^^^^^^^^^^^^^
240240
241241.. code-block :: python
242242
243- from VegasAfterglow import SynchrotronSelfCompton
243+ from VegasAfterglow import Radiation
244244
245- # Create a model with synchrotron self-Compton
246- ssc = SynchrotronSelfCompton(
247- epsilon_e = 0.1 ,
248- epsilon_B = 1e-3 , # Lower magnetization favors IC
249- p = 2.2 ,
250- include_KN = True # Include Klein-Nishina effects
251- )
252-
253- # Update the model
254- model.set_radiation(ssc)
255-
256- # Calculate over a broader frequency range to capture IC component
257- frequencies_broad = np.logspace(9 , 24 , 50 ) # Radio to gamma-rays
258-
259- # Calculate spectrum at a specific time
260- t_spec = 1e4 # 10,000 seconds
261- spectrum = model.calculate_spectrum(t_spec, frequencies_broad)
262-
263- # Plot the spectrum with components
264- plt.figure(figsize = (10 , 6 ))
265- plt.loglog(frequencies_broad, spectrum, ' b-' , label = ' Total' )
266- plt.loglog(frequencies_broad, model.get_synchrotron_spectrum(), ' r--' , label = ' Synchrotron' )
267- plt.loglog(frequencies_broad, model.get_ic_spectrum(), ' g--' , label = ' Inverse Compton' )
268-
269- plt.xlabel(' Frequency (Hz)' )
270- plt.ylabel(' Flux Density (erg/cm²/s/Hz)' )
271- plt.legend()
272- plt.title(f ' GRB Afterglow Spectrum at t = { t_spec} s ' )
273- plt.grid(True , which = ' both' , linestyle = ' --' , alpha = 0.5 )
274- plt.show()
245+ # Create a radiation model with inverse Compton cooling (with Klein-Nishina correction) on synchrotron radiation
246+ rad = Radiation(eps_e = 1e-1 , eps_B = 1e-3 , p = 2.3 , IC_cooling = True , KN = False )
275247
276- Advanced Features
277- -----------------
248+ # ..other settings
249+ model = Model(forward_rad = rad, ... )
250+
251+ Self-Synchrotron Compton Radiation
252+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
253+
254+ .. code-block :: python
255+
256+ from VegasAfterglow import Radiation
257+
258+ # Create a radiation model with self-Compton radiation
259+ rad = Radiation(eps_e = 1e-1 , eps_B = 1e-3 , p = 2.3 , SSC = True , KN = True , IC_cooling = True )
260+
261+ # ..other settings
262+ model = Model(forward_rad = rad, ... )
263+
264+ times = np.logspace(2 , 8 , 200 )
265+ bands = np.array([1e9 , 1e14 , 1e17 ])
266+
267+ results = model.specific_flux(times, bands)
268+
269+ plt.figure(figsize = (4.8 , 3.6 ),dpi = 200 )
270+
271+ # Plot each frequency band
272+ for i, nu in enumerate (bands):
273+ exp = int (np.floor(np.log10(nu)))
274+ base = nu / 10 ** exp
275+ plt.loglog(times, results[' syn' ][i,:], label = fr ' $ { base:.1f } \times 10^ {{ { exp} }} $ Hz ' )# synchrotron
276+ plt.loglog(times, results[' IC' ][i,:], label = fr ' $ { base:.1f } \times 10^ {{ { exp} }} $ Hz ' )# SSC
277+
278+ .. note ::
279+ (IC_cooling = False, KN = False, SSC = True): The IC radiation is calculated based on synchrotron spectrum without IC cooling.
280+ (IC_cooling = True, KN = False, SSC = True): The IC radiation is calculated based on synchrotron spectrum with IC cooling without Klein-Nishina correction.
281+ (IC_cooling = True, KN = True, SSC = True): The IC radiation is calculated based on synchrotron spectrum with IC cooling and Klein-Nishina correction.
278282
279283Reverse Shock
280284^^^^^^^^^^^^^
281285
282286.. code-block :: python
287+ from VegasAfterglow import Radiation
283288
284- # Create a model with reverse shock component
285- model_with_rs = Model(
286- jet = jet,
287- medium = medium,
288- radiation = radiation,
289- include_reverse_shock = True
290- )
291-
292- # Set reverse shock parameters
293- model_with_rs.set_reverse_shock_parameters(
294- RB = 0.1 , # Magnetic field ratio between reverse and forward shock
295- Re = 1.0 # Electron energy ratio between reverse and forward shock
296- )
297-
298- # Calculate light curves including reverse shock
299- results_with_rs = model_with_rs.calculate_light_curves(times, frequencies)
289+ # Create a radiation model with self-Compton radiation
290+ fwd_rad = Radiation(eps_e = 1e-1 , eps_B = 1e-3 , p = 2.3 , SSC = True , KN = True , IC_cooling = True )
291+ rvs_rad = Radiation(eps_e = 1e-2 , eps_B = 1e-4 , p = 2.4 , SSC = False , KN = False , IC_cooling = False )
292+
293+ # ..other settings
294+ model = Model(forward_rad = fwd_rad, reverse_rad = rvs_rad, ... )
295+
296+ times = np.logspace(2 , 8 , 200 )
297+ bands = np.array([1e9 , 1e14 , 1e17 ])
298+
299+ results = model.specific_flux(times, bands)
300300
301- # Plot forward vs reverse shock components
302- plt.figure(figsize = (10 , 6 ))
303- for i, nu in enumerate (frequencies):
304- plt.loglog(times, results_with_rs[:, i], label = f ' Total { nu:.1e } Hz ' )
305- plt.loglog(times, model_with_rs.get_forward_shock_light_curve(i), ' --' ,
306- label = f ' FS { nu:.1e } Hz ' )
307- plt.loglog(times, model_with_rs.get_reverse_shock_light_curve(i), ' :' ,
308- label = f ' RS { nu:.1e } Hz ' )
301+ plt.figure(figsize = (4.8 , 3.6 ),dpi = 200 )
302+
303+ # Plot each frequency band
304+ for i, nu in enumerate (bands):
305+ exp = int (np.floor(np.log10(nu)))
306+ base = nu / 10 ** exp
307+ plt.loglog(times, results[' syn' ][i,:], label = fr ' $ { base:.1f } \times 10^ {{ { exp} }} $ Hz ' )
308+ plt.loglog(times, results[' IC' ][i,:], label = fr ' $ { base:.1f } \times 10^ {{ { exp} }} $ Hz ' )
309+ plt.loglog(times, results[' syn_rvs' ][i,:], label = fr ' $ { base:.1f } \times 10^ {{ { exp} }} $ Hz ' )# reverse shock synchrotron
310+
311+ .. note ::
312+ You may increase the resolution of the grid to improve the accuracy of the reverse shock synchrotron radiation.
309313
310- plt.xlabel(' Time (s)' )
311- plt.ylabel(' Flux Density (erg/cm²/s/Hz)' )
312- plt.legend()
313- plt.title(' GRB Afterglow with Reverse Shock' )
314- plt.grid(True , which = ' both' , linestyle = ' --' , alpha = 0.5 )
315- plt.show()
314+ Advanced Features
315+ -----------------
316+
316317
317318MCMC Parameter Fitting
318319^^^^^^^^^^^^^^^^^^^^^^
0 commit comments