Write a point Kinetics solver with thermal feedback
- User
Write a point Kinetics solver with thermal feedback
- Assistant
Below is an example in Python that sets up and solves a simplified point‐kinetics model which includes thermal feedback. In this example, the neutron population, the concentrations of the delayed neutron groups, and the reactor (fuel) temperature are all coupled. The thermal feedback is modeled by letting the reactivity depend on the departure of the fuel temperature from its nominal value. (Keep in mind that actual reactor physics applications are far more detailed, but this example illustrates the basic ideas.)
The Model
The point kinetics equations (with six delayed neutron groups) are
[ \frac{dn}{dt} = \frac{\rho(t) - \beta}{\Lambda}, n + \sum_{i=1}^{6} \lambda_i C_i ]
[ \frac{dC_i}{dt} = \frac{\beta_i}{\Lambda}, n - \lambda_i C_i \quad (i=1,\ldots,6) ]
Here:
- (n(t)) is the neutron population (or a quantity proportional to reactor power).
- (C_i(t)) is the concentration of the (i)th delayed neutron precursor group.
- (\rho(t)) is the reactivity, which in our case includes an external insertion and a thermal feedback correction.
- (\beta = \sum \beta_i) is the total delayed neutron fraction.
- (\Lambda) is the prompt neutron generation time.
- (\lambda_i) is the decay constant for precursor group (i).
For the thermal feedback we assume the reactivity is given by
[ \rho(t) = \rho_\text{ext}(t) - \alpha (T(t)-T_0) ]
where
- (\rho_\text{ext}(t)) is an external reactivity insertion (for demonstration, a pulse between (t=10) s and (t=20) s).
- (T(t)) is the fuel temperature.
- (T_0) is the nominal (initial) temperature.
- (\alpha) is the feedback coefficient (per Kelvin).
The reactor temperature is assumed to change according to a simple balance equation
[ \frac{dT}{dt} = \kappa,n - \frac{(T-T_0)}{\tau} ]
where
- (\kappa) translates the neutron population (or power) into a temperature rise, and
- (\tau) is a time constant representing cooling (heat removal) effects.
Python Code
Below is the complete code example:
import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint def kinetics_thermal(y, t, params): """ ODE system including point kinetics with thermal feedback. y[0] : neutron population n y[1] : reactor temperature T y[2:] : precursor concentrations for each delayed group [C1, C2, ..., C6] """ # Unpack state variables n = y[0] T = y[1] C = y[2:] # Unpack parameters beta = params['beta'] beta_i = params['beta_i'] Lambda = params['Lambda'] lam = params['lambda'] T0 = params['T0'] alpha = params['alpha'] kappa = params['kappa'] tau = params['tau'] # External reactivity insertion: a pulse between 10 and 20 seconds. rho_ext = params['rho_ext'](t) # Thermal reactivity feedback: reactor gets negative reactivity when T > T0. rho = rho_ext - alpha * (T - T0) # Point kinetics equations: dn_dt = (rho - beta) / Lambda * n + np.sum(lam * C) dC_dt = beta_i / Lambda * n - lam * C # element-wise for each delayed group # Thermal feedback model: dT_dt = kappa * n - (T - T0) / tau # Return the derivatives as a concatenated vector. return np.concatenate(([dn_dt, dT_dt], dC_dt)) # --- Set Model Parameters --- params = {} # Delayed neutron data for 6 groups (example values) params['beta'] = 0.006 # total delayed neutron fraction params['beta_i'] = np.array([0.0005, 0.0010, 0.0012, 0.0015, 0.0008, 0.0000]) # example fractions; note sum ≠ beta, adjust as needed # In a realistic model, these should sum to beta (or be normalized appropriately). params['Lambda'] = 1e-4 # prompt neutron generation time (seconds) # Decay constants for the delayed neutron precursor groups (1/s) params['lambda'] = np.array([0.0124, 0.0305, 0.111, 0.301, 1.14, 3.01]) # Thermal feedback parameters params['T0'] = 300 # nominal temperature in Kelvin params['alpha'] = 0.001 # feedback coefficient (reactivity change per Kelvin) params['kappa'] = 1e-5 # temperature rise rate per unit neutron population params['tau'] = 100 # effective cooling (heat removal) time constant (seconds) # External reactivity: a function that produces a reactivity pulse between 10s and 20s. params['rho_ext'] = lambda t: 0.0005 if 10 < t < 20 else 0.0 # --- Initial Conditions --- # Assume at steady state: neutron population is normalized to 1. n0 = 1.0 # For precursors at steady state: C_i0 = (beta_i / (lambda_i * Lambda)) * n0. C0 = params['beta_i'] / (params['lambda'] * params['Lambda']) * n0 T0 = params['T0'] # initial temperature # Combine initial conditions into a single vector: [n, T, C1, C2, ... C6] y0 = np.concatenate(([n0, T0], C0)) # --- Time Grid for Simulation --- t = np.linspace(0, 100, 1000) # simulate 0 to 100 seconds # --- Solve the ODE System --- sol = odeint(kinetics_thermal, y0, t, args=(params,)) # Extract solutions n_sol = sol[:, 0] T_sol = sol[:, 1] # Precursor concentrations are in sol[:, 2:], if needed # --- Plot the Results --- plt.figure(figsize=(12, 8)) # Plot neutron population over time plt.subplot(2, 1, 1) plt.plot(t, n_sol, 'b-', label='Neutron Population, n(t)') plt.xlabel('Time (s)') plt.ylabel('Relative Neutron Population') plt.title('Point Kinetics with Thermal Feedback') plt.legend() plt.grid() # Plot reactor temperature over time plt.subplot(2, 1, 2) plt.plot(t, T_sol, 'r-', label='Temperature, T(t)') plt.xlabel('Time (s)') plt.ylabel('Temperature (K)') plt.legend() plt.grid() plt.tight_layout() plt.show()Explanation
-
Model Function (
kinetics_thermal):
This function computes the time derivatives (\frac{dn}{dt}), (\frac{dC_i}{dt}), and (\frac{dT}{dt}) based on the current state and parameters. The reactivity (\rho) is computed by combining an externally inserted reactivity ((\rho_\text{ext})) with a thermal feedback term (-\alpha (T-T_0)). -
Parameters:
The delayed neutron fractions, decay constants, neutron generation time, and thermal feedback constants (e.g., (\alpha), (\kappa), (\tau)) are defined. Adjust these to match more realistic or specific conditions as needed. -
Initial Conditions:
The steady-state condition is assumed so that initially the neutron population is 1 and the precursor concentrations are calculated accordingly. The temperature starts at (T_0). -
Solving the ODE:
The Python functionodeintfrom thescipy.integratemodule integrates the system over a defined time grid. -
Plotting:
Two subplots show how the neutron population and temperature evolve over time. The example external reactivity pulse (from 10 s to 20 s) provides a transient that demonstrates the feedback effect.
This code can serve as a starting point for more detailed studies of reactor kinetics with thermal feedback. Adjust and expand the model as necessary for more complex scenarios or more accurate reactor physics.
- User
Add a control rod gradual insertion
- Assistant
Below is the updated code for a point kinetics solver that now includes both thermal feedback and a gradual control rod insertion. In this example, we assume that in addition to an external reactivity pulse between 10 and 20 seconds, a control rod begins inserting at a specified time and continues gradually until it reaches its maximum insertion, which produces an additional negative reactivity. You can adjust the timing and magnitude parameters to suit your needs.
The reactivity now has three contributions:
- An external reactivity insertion (a pulse between 10 and 20 seconds).
- A control rod insertion that ramps linearly from no insertion to full insertion over a specified time interval.
- A thermal feedback term proportional to the temperature deviation ((T - T_0)).
Below is the complete Python code:
import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint def kinetics_thermal_control(y, t, params): """ ODE system for point kinetics with thermal feedback and control rod insertion. y[0] : neutron population n y[1] : reactor temperature T y[2:] : precursor concentrations for each delayed group [C1, C2, ..., C6] """ # Unpack state variables n = y[0] T = y[1] C = y[2:] # Unpack kinetics parameters beta = params['beta'] beta_i = params['beta_i'] Lambda = params['Lambda'] lam = params['lambda'] # Unpack thermal parameters T0 = params['T0'] alpha = params['alpha'] kappa = params['kappa'] tau = params['tau'] # --- Calculate External Reactivity Insertion --- # (a pulse between 10 s and 20 s) rho_ext = params['rho_ext'](t) # --- Calculate Control Rod Reactivity --- # The control rod insertion is assumed to begin at t = rod_start and be complete at t = rod_end. # The rod insertion creates a *negative* reactivity that ramps up linearly. rod_start = params['rod_start'] rod_end = params['rod_end'] rho_rod_max = params['rho_rod_max'] # maximum negative reactivity magnitude (a positive number to be subtracted) if t < rod_start: rho_rod = 0.0 elif rod_start <= t < rod_end: # Linear ramp: goes from 0 to -rho_rod_max fraction = (t - rod_start) / (rod_end - rod_start) rho_rod = -fraction * rho_rod_max else: rho_rod = -rho_rod_max # --- Total Reactivity --- # Thermal feedback is negative when T > T0. # Total reactivity is the sum of the external, control rod, and thermal feedback reactivities. rho = rho_ext + rho_rod - alpha * (T - T0) # --- Point Kinetics Equations --- dn_dt = ((rho - beta) / Lambda) * n + np.sum(lam * C) dC_dt = beta_i / Lambda * n - lam * C # element-wise for each of the 6 delayed groups # --- Thermal Balance Equation --- dT_dt = kappa * n - (T - T0) / tau # Return the derivatives as a single concatenated vector. return np.concatenate(([dn_dt, dT_dt], dC_dt)) # --- Set Model Parameters --- params = {} # Delayed neutron data for 6 groups (example values) params['beta'] = 0.006 # total delayed neutron fraction params['beta_i'] = np.array([0.0005, 0.0010, 0.0012, 0.0015, 0.0008, 0.0000]) # For a realistic model, ensure that sum(beta_i) equals beta. params['Lambda'] = 1e-4 # prompt neutron generation time in seconds # Decay constants for each delayed neutron precursor group (1/s) params['lambda'] = np.array([0.0124, 0.0305, 0.111, 0.301, 1.14, 3.01]) # Thermal feedback parameters params['T0'] = 300 # Nominal (initial) temperature in Kelvin params['alpha'] = 0.001 # Feedback coefficient (reactivity change per Kelvin) params['kappa'] = 1e-5 # Temperature rise rate per unit neutron population params['tau'] = 100 # Cooling time constant (seconds) # External reactivity insertion: a pulse between 10s and 20s. params['rho_ext'] = lambda t: 0.0005 if 10 < t < 20 else 0.0 # Control rod insertion parameters params['rod_start'] = 50 # Time when control rod insertion starts (seconds) params['rod_end'] = 70 # Time when control rod insertion is complete (seconds) params['rho_rod_max'] = 0.002 # Maximum negative reactivity due to rod insertion # --- Initial Conditions --- # At steady-state: normalized neutron population n = 1. n0 = 1.0 # Steady-state precursor concentrations: C_i0 = (beta_i / (lambda_i * Lambda)) * n0. C0 = params['beta_i'] / (params['lambda'] * params['Lambda']) * n0 T0 = params['T0'] # initial temperature # Combine all initial conditions into one vector: [n, T, C1, C2, ... C6] y0 = np.concatenate(([n0, T0], C0)) # --- Time Grid for Simulation --- t = np.linspace(0, 120, 1200) # simulate from 0 to 120 seconds # --- Solve the ODE System --- sol = odeint(kinetics_thermal_control, y0, t, args=(params,)) # Extract solutions n_sol = sol[:, 0] # neutron population T_sol = sol[:, 1] # temperature # Precursor concentrations are in sol[:, 2:], if needed for further analysis # --- Plot the Results --- plt.figure(figsize=(12, 10)) # Plot neutron population over time plt.subplot(3, 1, 1) plt.plot(t, n_sol, 'b-', label='Neutron Population, n(t)') plt.xlabel('Time (s)') plt.ylabel('Relative Neutron Population') plt.title('Point Kinetics with Thermal Feedback & Control Rod Insertion') plt.legend() plt.grid() # Plot reactor temperature over time plt.subplot(3, 1, 2) plt.plot(t, T_sol, 'r-', label='Temperature, T(t)') plt.xlabel('Time (s)') plt.ylabel('Temperature (K)') plt.legend() plt.grid() # Plot total reactivity over time for reference. # We compute it separately using the same expressions as in the ODE function. rho_total = [] for time in t: # External reactivity r_ext = params['rho_ext'](time) # Control rod reactivity if time < params['rod_start']: r_rod = 0.0 elif params['rod_start'] <= time < params['rod_end']: fraction = (time - params['rod_start']) / (params['rod_end'] - params['rod_start']) r_rod = -fraction * params['rho_rod_max'] else: r_rod = -params['rho_rod_max'] # Thermal feedback is not plotted here because it requires T(t). # Instead, we plot the sum of the external and control rod reactivities. rho_total.append(r_ext + r_rod) plt.subplot(3, 1, 3) plt.plot(t, rho_total, 'k-', label='(External + Control Rod) Reactivity') plt.xlabel('Time (s)') plt.ylabel('Reactivity (Δk/k)') plt.legend() plt.grid() plt.tight_layout() plt.show()
Explanation
-
Reactivity Contributions:
- External Reactivity (
rho_ext) remains the same—a pulse active between 10 and 20 seconds. - Control Rod Insertion:
The parametersrod_start,rod_end, andrho_rod_maxdefine when the control rod begins to insert, when the insertion is complete, and the maximum negative reactivity insertion value, respectively. During insertion, the rod effect ramps linearly from 0 to (-\rho_{rod_max}). - Thermal Feedback:
As before, a feedback term (-\alpha (T-T_0)) is subtracted to mimic the negative reactivity due to fuel temperature rise.
- External Reactivity (
-
ODE Function (
kinetics_thermal_control):
This function calculates the time derivatives for the neutron population, temperature, and precursor concentrations using the modified reactivity that now includes the control rod effect. -
Initial Conditions & Solver:
The initial steady-state conditions are computed, andodeintintegrates the set of equations over a defined time grid. -
Plotting:
- The top subplot shows the evolution of the neutron population over time.
- The middle subplot shows the temperature.
- The bottom subplot provides a reference graph for the sum of the external and control rod reactivities (thermal feedback is not shown separately here as it depends on (T(t))).
This example provides a basic framework that you can modify or expand for more detailed reactor kinetics studies, including more sophisticated control rod behavior.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.