Это код, который я пробовал:
Код: Выделить всё
import numpy as np
from scipy.integrate import odeint
# Define the function representing the differential equations
def system(y, t, phi0, lambda_val, epsilon):
rho, phi, r = y
# Isotope density decay equation
drho_dt = -lambda_val * rho
# Change in energy of photonic reactants equation
dphi_dt = phi - phi0
# Gravitational force equation
F = G * epsilon / r**2
# Properties of the gravatomic spectrum equation
sigma = F / dphi_dt
return [drho_dt, dphi_dt, sigma]
# Define initial conditions
rho0 = 1.0 # Initial isotope density
phi0 = 0.0 # Baseline energy of photonic reactants
r0 = 1.0 # Initial distance
# Set parameters
lambda_val = 0.1 # Decay constant
G = 6.67430e-11 # Gravitational constant
epsilon = 1.0 # Efficiency factor of gravitational interaction
# Create time points for integration
t = np.linspace(0, 10, 100)
# Initial values
y0 = [rho0, phi0, r0]
# Solve the system of ODEs
sol = odeint(system, y0, t, args=(phi0, lambda_val, epsilon))
# Extract the solutions
rho_sol = sol[:, 0]
phi_sol = sol[:, 1]
sigma_sol = sol[:, 2]
Код: Выделить всё
RuntimeWarning: divide by zero encountered in scalar divide sigma = F / dphi_dt ODEintWarning: Illegal input detected (internal error). Run with full_output = 1 to get quantitative information. sol = odeint(system, y0, t, args=(phi0, lambda_val, epsilon))Подробнее здесь: https://stackoverflow.com/questions/784 ... terparts-i