0
0

環境の数学

Last updated at Posted at 2024-08-15
# Conversion functions
def percent_to_ppm(percent):
    """
    Convert percentage to parts per million (ppm).
    
    Args:
    percent (float): The percentage value to convert.
    
    Returns:
    float: The equivalent ppm value.
    """
    return percent * 10000

def ppm_to_percent(ppm):
    """
    Convert parts per million (ppm) to percentage.
    
    Args:
    ppm (float): The ppm value to convert.
    
    Returns:
    float: The equivalent percentage value.
    """
    return ppm / 10000

# Example usage
if __name__ == "__main__":
    # Convert 0.0005% to ppm
    percent_value = 0.0005
    ppm_value = percent_to_ppm(percent_value)
    print(f"{percent_value}% is equivalent to {ppm_value} ppm")

    # Convert 10 ppm to percentage
    ppm_value = 10
    percent_value = ppm_to_percent(ppm_value)
    print(f"{ppm_value} ppm is equivalent to {percent_value}%")

    # Example of ppm usage
    # Air Pollution
    co_concentration = 5  # CO concentration in ppm
    print(f"CO concentration in air: {co_concentration} ppm")

    # Medical Testing
    co_concentration_smoker = 30  # CO concentration in ppm for heavy smoker
    print(f"CO concentration in breath for heavy smoker: {co_concentration_smoker} ppm")

    # Product Portfolio Management (PPM as management term)
    # Example (not directly calculable, just for context)
    print("In product management, PPM might refer to Product Portfolio Management, not parts per million.")
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats

# 1. Biochemical Oxygen Demand (BOD) Calculation
def bod_initial_concentration(C0, k, t):
    """
    Calculate BOD at time t using the first-order decay model.
    
    Args:
    C0 (float): Initial concentration (mg/L)
    k (float): Decay rate constant (1/day)
    t (float): Time (days)
    
    Returns:
    float: BOD at time t (mg/L)
    """
    return C0 * (1 - np.exp(-k * t))

# Parameters for BOD
C0 = 100  # mg/L
k = 0.1   # 1/day
t = np.linspace(0, 10, 100)  # days
bod_values = bod_initial_concentration(C0, k, t)

# 2. Radioactive Decay
def radioactive_decay(N0, decay_constant, t):
    """
    Calculate the remaining quantity of a radioactive substance at time t.
    
    Args:
    N0 (float): Initial quantity
    decay_constant (float): Decay constant (1/time)
    t (float or array): Time (time units)
    
    Returns:
    float or array: Remaining quantity at time t
    """
    return N0 * np.exp(-decay_constant * t)

# Parameters for radioactive decay
N0 = 1000  # Initial quantity
decay_constant = 0.05  # 1/day
time_decay = np.linspace(0, 100, 100)  # days
remaining_quantity = radioactive_decay(N0, decay_constant, time_decay)

# 3. Photosynthesis Rate (simplified)
def photosynthesis_rate(light_intensity, rate_constant):
    """
    Estimate the rate of photosynthesis based on light intensity.
    
    Args:
    light_intensity (float): Light intensity (arbitrary units)
    rate_constant (float): Rate constant
    
    Returns:
    float: Rate of photosynthesis
    """
    return rate_constant * light_intensity

# Parameters for photosynthesis
light_intensity = np.linspace(0, 1000, 100)  # arbitrary units
rate_constant = 0.05
photosynthesis = photosynthesis_rate(light_intensity, rate_constant)

# 4. Normal Distribution
mu, sigma = 0, 1  # mean and standard deviation
x = np.linspace(-5, 5, 100)
normal_dist = stats.norm.pdf(x, mu, sigma)

# 5. Suspension Curve (example function)
def suspension_curve(x, a, b, c):
    """
    Example suspension curve function.
    
    Args:
    x (array): Independent variable
    a, b, c (float): Parameters
    
    Returns:
    array: Dependent variable
    """
    return a * np.exp(-b * x) + c

# Parameters for suspension curve
a, b, c = 10, 0.1, 2
x_suspension = np.linspace(0, 10, 100)
suspension = suspension_curve(x_suspension, a, b, c)

# Plotting
plt.figure(figsize=(15, 12))

# BOD Plot
plt.subplot(3, 2, 1)
plt.plot(t, bod_values, label='BOD')
plt.title('Biochemical Oxygen Demand (BOD)')
plt.xlabel('Time (days)')
plt.ylabel('BOD (mg/L)')
plt.grid(True)

# Radioactive Decay Plot
plt.subplot(3, 2, 2)
plt.plot(time_decay, remaining_quantity, label='Radioactive Decay', color='orange')
plt.title('Radioactive Decay')
plt.xlabel('Time (days)')
plt.ylabel('Remaining Quantity')
plt.grid(True)

# Photosynthesis Rate Plot
plt.subplot(3, 2, 3)
plt.plot(light_intensity, photosynthesis, label='Photosynthesis Rate', color='green')
plt.title('Photosynthesis Rate')
plt.xlabel('Light Intensity')
plt.ylabel('Photosynthesis Rate')
plt.grid(True)

# Normal Distribution Plot
plt.subplot(3, 2, 4)
plt.plot(x, normal_dist, label='Normal Distribution', color='blue')
plt.title('Normal Distribution')
plt.xlabel('x')
plt.ylabel('Probability Density')
plt.grid(True)

# Suspension Curve Plot
plt.subplot(3, 2, 5)
plt.plot(x_suspension, suspension, label='Suspension Curve', color='red')
plt.title('Suspension Curve')
plt.xlabel('x')
plt.ylabel('Value')
plt.grid(True)

plt.tight_layout()
plt.show()

import numpy as np
import matplotlib.pyplot as plt

# Define Steel's equation function
def steele_equation(S, V_max, K_m):
    """
    Calculate the reaction rate using Steel's equation.
    
    Args:
    S (array): Substrate concentration
    V_max (float): Maximum reaction rate
    K_m (float): Michaelis constant
    
    Returns:
    array: Reaction rate
    """
    return (V_max * S) / (K_m + S)

# Parameters
V_max = 100  # Maximum reaction rate
K_m = 50     # Michaelis constant

# Substrate concentration range
S = np.linspace(0, 200, 400)

# Calculate reaction rate
reaction_rate = steele_equation(S, V_max, K_m)

# Plotting
plt.figure(figsize=(8, 6))
plt.plot(S, reaction_rate, label='Reaction Rate', color='blue')
plt.title("Steele's Equation")
plt.xlabel('Substrate Concentration (S)')
plt.ylabel('Reaction Rate (v)')
plt.grid(True)
plt.legend()
plt.show()


import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats

# 6.3 Biochemical Oxygen Demand (BOD)
def bod_initial_concentration(C0, k, t):
    """
    Calculate BOD at time t using the first-order decay model.
    
    Args:
    C0 (float): Initial concentration (mg/L)
    k (float): Decay rate constant (1/day)
    t (float): Time (days)
    
    Returns:
    float: BOD at time t (mg/L)
    """
    return C0 * (1 - np.exp(-k * t))

# 6.4 Radioactive Decay
def radioactive_decay(N0, decay_constant, t):
    """
    Calculate the remaining quantity of a radioactive substance at time t.
    
    Args:
    N0 (float): Initial quantity
    decay_constant (float): Decay constant (1/time)
    t (float or array): Time (time units)
    
    Returns:
    float or array: Remaining quantity at time t
    """
    return N0 * np.exp(-decay_constant * t)

# 6.5 Malthusian Growth Model
def malthusian_growth(P0, r, t):
    """
    Calculate the population size using the Malthusian growth model.
    
    Args:
    P0 (float): Initial population
    r (float): Growth rate
    t (float or array): Time
    
    Returns:
    float or array: Population size at time t
    """
    return P0 * np.exp(r * t)

# 6.6 Logistic Equation (1) - Basic
def logistic_growth_1(P0, r, K, t):
    """
    Logistic growth model.
    
    Args:
    P0 (float): Initial population
    r (float): Growth rate
    K (float): Carrying capacity
    t (float or array): Time
    
    Returns:
    float or array: Population size at time t
    """
    return K / (1 + ((K - P0) / P0) * np.exp(-r * t))

# 6.7 Logistic Equation (2) - Extended
def logistic_growth_2(P0, r, K, t, a):
    """
    Extended logistic growth model including additional parameter a.
    
    Args:
    P0 (float): Initial population
    r (float): Growth rate
    K (float): Carrying capacity
    t (float or array): Time
    a (float): Additional parameter affecting growth
    
    Returns:
    float or array: Population size at time t
    """
    return K / (1 + ((K - P0) / P0) * np.exp(-r * t)) ** a

# 6.8 Maximum Sustainable Yield (MSY) and Resource Management
def msy_and_resource_management(P0, r, K, t, catch_limit):
    """
    Model resource management with MSY and a catch limit.
    
    Args:
    P0 (float): Initial population
    r (float): Growth rate
    K (float): Carrying capacity
    t (float or array): Time
    catch_limit (float): Catch limit
    
    Returns:
    float or array: Population size after accounting for catch limit
    """
    population = logistic_growth_1(P0, r, K, t)
    return population - catch_limit

# Parameters
C0 = 100  # mg/L for BOD
k = 0.1   # 1/day for BOD
t_bod = np.linspace(0, 10, 100)  # Time range for BOD

N0 = 1000  # Initial quantity for decay
decay_constant = 0.05  # 1/day for decay
t_decay = np.linspace(0, 100, 100)  # Time range for decay

P0_malthus = 50  # Initial population for Malthusian model
r_malthus = 0.1  # Growth rate for Malthusian model
t_malthus = np.linspace(0, 50, 100)  # Time range for Malthusian model

P0_logistic = 50  # Initial population for logistic growth
r_logistic = 0.1  # Growth rate for logistic model
K_logistic = 500  # Carrying capacity for logistic model
t_logistic = np.linspace(0, 50, 100)  # Time range for logistic model

a_logistic = 2  # Additional parameter for extended logistic model

catch_limit = 20  # Catch limit for resource management

# Calculations
bod_values = bod_initial_concentration(C0, k, t_bod)
remaining_quantity = radioactive_decay(N0, decay_constant, t_decay)
malthusian_population = malthusian_growth(P0_malthus, r_malthus, t_malthus)
logistic_population = logistic_growth_1(P0_logistic, r_logistic, K_logistic, t_logistic)
extended_logistic_population = logistic_growth_2(P0_logistic, r_logistic, K_logistic, t_logistic, a_logistic)
managed_population = msy_and_resource_management(P0_logistic, r_logistic, K_logistic, t_logistic, catch_limit)

# Plotting
plt.figure(figsize=(18, 14))

# BOD Plot
plt.subplot(3, 3, 1)
plt.plot(t_bod, bod_values, label='BOD')
plt.title('Biochemical Oxygen Demand (BOD)')
plt.xlabel('Time (days)')
plt.ylabel('BOD (mg/L)')
plt.grid(True)

# Radioactive Decay Plot
plt.subplot(3, 3, 2)
plt.plot(t_decay, remaining_quantity, label='Radioactive Decay', color='orange')
plt.title('Radioactive Decay')
plt.xlabel('Time (days)')
plt.ylabel('Remaining Quantity')
plt.grid(True)

# Malthusian Growth Plot
plt.subplot(3, 3, 3)
plt.plot(t_malthus, malthusian_population, label='Malthusian Growth', color='green')
plt.title('Malthusian Growth Model')
plt.xlabel('Time')
plt.ylabel('Population Size')
plt.grid(True)

# Logistic Growth (1) Plot
plt.subplot(3, 3, 4)
plt.plot(t_logistic, logistic_population, label='Logistic Growth (1)', color='blue')
plt.title('Logistic Growth Model (1)')
plt.xlabel('Time')
plt.ylabel('Population Size')
plt.grid(True)

# Extended Logistic Growth (2) Plot
plt.subplot(3, 3, 5)
plt.plot(t_logistic, extended_logistic_population, label='Extended Logistic Growth (2)', color='red')
plt.title('Extended Logistic Growth Model (2)')
plt.xlabel('Time')
plt.ylabel('Population Size')
plt.grid(True)

# Resource Management with MSY Plot
plt.subplot(3, 3, 6)
plt.plot(t_logistic, managed_population, label='Managed Population', color='purple')
plt.title('MSY and Resource Management')
plt.xlabel('Time')
plt.ylabel('Population Size')
plt.grid(True)

plt.tight_layout()
plt.show()


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Define Gaussian dispersion model
def gaussian_dispersion(Q, u, sigma_y, sigma_z, x, y, z):
    """
    Calculate the concentration of pollutants using the Gaussian dispersion model.
    
    Args:
    Q (float): Emission rate (g/s)
    u (float): Wind speed (m/s)
    sigma_y (float): Horizontal dispersion coefficient (m)
    sigma_z (float): Vertical dispersion coefficient (m)
    x (array): Distance downwind (m)
    y (array): Lateral distance (m)
    z (array): Vertical distance (m)
    
    Returns:
    array: Concentration of pollutants (g/m^3)
    """
    return (Q / (2 * np.pi * sigma_y * sigma_z * u)) * np.exp(-y**2 / (2 * sigma_y**2)) * np.exp(-z**2 / (2 * sigma_z**2))

# Parameters
Q = 100  # Emission rate (g/s)
u = 5    # Wind speed (m/s)
sigma_y = 50  # Horizontal dispersion coefficient (m)
sigma_z = 10  # Vertical dispersion coefficient (m)

# Create grid
x = np.linspace(0, 1000, 100)  # Downwind distance
y = np.linspace(-500, 500, 100)  # Lateral distance
z = np.linspace(-100, 100, 50)  # Vertical distance
X, Y, Z = np.meshgrid(x, y, z)

# Calculate concentration
C = gaussian_dispersion(Q, u, sigma_y, sigma_z, X, Y, Z)

# Plotting 2D cross-section
plt.figure(figsize=(14, 6))

plt.subplot(1, 2, 1)
plt.contourf(X[:, :, 0], Y[:, :, 0], C[:, :, 0], levels=100, cmap='viridis')
plt.colorbar(label='Concentration (g/m^3)')
plt.title('2D Cross-Section (z=0)')
plt.xlabel('Distance downwind (m)')
plt.ylabel('Lateral distance (m)')

# Plotting 3D view
fig = plt.figure(figsize=(14, 6))
ax = fig.add_subplot(111, projection='3d')
X_flat = X[:, :, 0].flatten()
Y_flat = Y[:, :, 0].flatten()
C_flat = C[:, :, 0].flatten()
ax.scatter(X_flat, Y_flat, C_flat, c=C_flat, cmap='viridis', marker='o', alpha=0.5)
ax.set_title('3D View of Pollutant Concentration')
ax.set_xlabel('Distance downwind (m)')
ax.set_ylabel('Lateral distance (m)')
ax.set_zlabel('Concentration (g/m^3)')

plt.tight_layout()
plt.show()


import numpy as np
import matplotlib.pyplot as plt

# Parameters for water treatment
def coagulation_efficiency(coagulation_dose, floc_size):
    return 1 - np.exp(-coagulation_dose / floc_size)

def sedimentation_efficiency(settling_velocity, time):
    return 1 - np.exp(-settling_velocity * time)

# Parameters for wastewater treatment
def biological_oxygen_demand(BOD_initial, k, t):
    return BOD_initial * np.exp(-k * t)

def sludge_volume_index(SVI_initial, t):
    return SVI_initial * (1 + 0.1 * t)

# Define parameters
coagulation_dose = np.linspace(0, 10, 100)  # Coagulation dose
floc_size = 5  # Floc size
settling_velocity = 0.1  # Settling velocity (m/s)
time_sedimentation = np.linspace(0, 10, 100)  # Time for sedimentation

BOD_initial = 200  # Initial BOD (mg/L)
k = 0.1  # Decay rate (1/day)
time_bod = np.linspace(0, 30, 100)  # Time for BOD calculation

SVI_initial = 150  # Initial SVI (mL/g)
time_svi = np.linspace(0, 30, 100)  # Time for SVI calculation

# Calculate efficiencies
coagulation_eff = coagulation_efficiency(coagulation_dose, floc_size)
sedimentation_eff = sedimentation_efficiency(settling_velocity, time_sedimentation)
BOD = biological_oxygen_demand(BOD_initial, k, time_bod)
SVI = sludge_volume_index(SVI_initial, time_svi)

# Plotting
plt.figure(figsize=(14, 10))

# Coagulation Efficiency Plot
plt.subplot(2, 2, 1)
plt.plot(coagulation_dose, coagulation_eff, color='blue')
plt.title('Coagulation Efficiency')
plt.xlabel('Coagulation Dose')
plt.ylabel('Efficiency')
plt.grid(True)

# Sedimentation Efficiency Plot
plt.subplot(2, 2, 2)
plt.plot(time_sedimentation, sedimentation_eff, color='green')
plt.title('Sedimentation Efficiency')
plt.xlabel('Time (s)')
plt.ylabel('Efficiency')
plt.grid(True)

# BOD Plot
plt.subplot(2, 2, 3)
plt.plot(time_bod, BOD, color='red')
plt.title('Biological Oxygen Demand (BOD)')
plt.xlabel('Time (days)')
plt.ylabel('BOD (mg/L)')
plt.grid(True)

# SVI Plot
plt.subplot(2, 2, 4)
plt.plot(time_svi, SVI, color='orange')
plt.title('Sludge Volume Index (SVI)')
plt.xlabel('Time (days)')
plt.ylabel('SVI (mL/g)')
plt.grid(True)

plt.tight_layout()
plt.show()

import numpy as np
import matplotlib.pyplot as plt

# Water pollution model parameters
def pollution_concentration(C0, k, t, D, L):
    return C0 * np.exp(-k * t) * np.exp(-D * t / L)

# Soil pollution model parameters
def soil_pollution_concentration(C0, k, t, A, B):
    return C0 * np.exp(-k * t) / (A + B * t)

# Parameters for water pollution
C0_water = 100  # Initial concentration (mg/L)
k_water = 0.05  # Degradation rate constant (1/day)
D = 0.1  # Diffusion coefficient (m^2/day)
L = 1000  # Length of the river (m)
time_water = np.linspace(0, 100, 100)  # Time (days)

# Parameters for soil pollution
C0_soil = 200  # Initial concentration (mg/kg)
k_soil = 0.03  # Degradation rate constant (1/day)
A = 50  # Adsorption coefficient
B = 0.05  # Migration coefficient
time_soil = np.linspace(0, 100, 100)  # Time (days)

# Calculate concentrations
concentration_water = pollution_concentration(C0_water, k_water, time_water, D, L)
soil_concentration = soil_pollution_concentration(C0_soil, k_soil, time_soil, A, B)

# Plotting
plt.figure(figsize=(14, 6))

# Water pollution concentration plot
plt.subplot(1, 2, 1)
plt.plot(time_water, concentration_water, color='blue')
plt.title('Water Pollution Concentration Over Time')
plt.xlabel('Time (days)')
plt.ylabel('Concentration (mg/L)')
plt.grid(True)

# Soil pollution concentration plot
plt.subplot(1, 2, 2)
plt.plot(time_soil, soil_concentration, color='green')
plt.title('Soil Pollution Concentration Over Time')
plt.xlabel('Time (days)')
plt.ylabel('Concentration (mg/kg)')
plt.grid(True)

plt.tight_layout()
plt.show()


import numpy as np
import matplotlib.pyplot as plt

# 悪臭モデルのパラメータ
def odor_concentration(C0, k, t):
    return C0 * np.exp(-k * t)

# 騒音モデルのパラメータ
def noise_level(L0, d, d0):
    return L0 - 20 * np.log10(d / d0)

# パラメータ設定
# 悪臭のパラメータ
C0_odor = 100  # 初期濃度 (mg/m³)
k_odor = 0.1   # 減衰率定数 (1/day)
time_odor = np.linspace(0, 100, 100)  # 時間 (days)

# 騒音のパラメータ
L0_noise = 80  # 初期騒音レベル (dB)
d0 = 1         # 基準距離 (m)
distance_noise = np.linspace(1, 1000, 100)  # 距離 (m)

# 濃度と騒音レベルの計算
odor_concentration_values = odor_concentration(C0_odor, k_odor, time_odor)
noise_level_values = noise_level(L0_noise, distance_noise, d0)

# プロット
plt.figure(figsize=(14, 6))

# 悪臭の濃度プロット
plt.subplot(1, 2, 1)
plt.plot(time_odor, odor_concentration_values, color='purple')
plt.title('Odor Concentration Over Time')
plt.xlabel('Time (days)')
plt.ylabel('Concentration (mg/m³)')
plt.grid(True)

# 騒音レベルのプロット
plt.subplot(1, 2, 2)
plt.plot(distance_noise, noise_level_values, color='red')
plt.title('Noise Level Over Distance')
plt.xlabel('Distance (m)')
plt.ylabel('Noise Level (dB)')
plt.grid(True)

plt.tight_layout()
plt.show()


import numpy as np
import matplotlib.pyplot as plt

# 廃棄物生成モデルのパラメータ
def waste_generation(W0, r, t):
    return W0 * np.exp(r * t)

# リサイクルモデルのパラメータ
def recycling_process(R0, k, t):
    return R0 * (1 - np.exp(-k * t))

# パラメータ設定
# 廃棄物生成のパラメータ
W0 = 50  # 初期廃棄物量 (トン)
r = 0.05  # 増加率 (1/年)
time = np.linspace(0, 20, 100)  # 時間 (年)

# リサイクルのパラメータ
R0 = 40  # 最大リサイクル量 (トン)
k = 0.1   # リサイクル速度定数 (1/年)

# 廃棄物生成量とリサイクル量の計算
waste_generation_values = waste_generation(W0, r, time)
recycling_values = recycling_process(R0, k, time)

# プロット
plt.figure(figsize=(14, 6))

# 廃棄物生成量のプロット
plt.subplot(1, 2, 1)
plt.plot(time, waste_generation_values, color='green')
plt.title('Waste Generation Over Time')
plt.xlabel('Time (years)')
plt.ylabel('Waste Generation (tons)')
plt.grid(True)

# リサイクル量のプロット
plt.subplot(1, 2, 2)
plt.plot(time, recycling_values, color='blue')
plt.title('Recycling Process Over Time')
plt.xlabel('Time (years)')
plt.ylabel('Recycling (tons)')
plt.grid(True)

plt.tight_layout()
plt.show()


import numpy as np
import matplotlib.pyplot as plt

# オゾン層モデルのパラメータ
def ozone_concentration(O3_0, k, P, t):
    return O3_0 * np.exp(-k * t) + (P / k) * (1 - np.exp(-k * t))

# 有害物質の影響のモデル
def destruction_rate(alpha, CFC_concentration):
    return alpha * CFC_concentration

# パラメータ設定
# オゾン層のパラメータ
O3_0 = 300  # 初期オゾン濃度 (ppb)
k = 0.02    # 破壊定数 (1/day)
P = 10      # 生成率 (ppb/day)
time = np.linspace(0, 365, 100)  # 時間 (days)

# 有害物質のパラメータ
CFC_concentration = 50  # CFC濃度 (ppb)
alpha = 0.05            # 破壊係数 (ppb per CFC concentration)

# オゾン濃度と破壊率の計算
ozone_concentration_values = ozone_concentration(O3_0, k, P, time)
destruction_rate_values = destruction_rate(alpha, CFC_concentration)

# プロット
plt.figure(figsize=(14, 6))

# オゾン濃度のプロット
plt.subplot(1, 2, 1)
plt.plot(time, ozone_concentration_values, color='blue')
plt.title('Ozone Concentration Over Time')
plt.xlabel('Time (days)')
plt.ylabel('Ozone Concentration (ppb)')
plt.grid(True)

# 有害物質の影響のプロット
plt.subplot(1, 2, 2)
plt.axhline(y=destruction_rate_values, color='red', linestyle='--', label=f'CFC Destruction Rate ({destruction_rate_values} ppb)')
plt.title('Impact of Harmful Substances')
plt.xlabel('Time (days)')
plt.ylabel('Destruction Rate (ppb)')
plt.legend()
plt.grid(True)

plt.tight_layout()
plt.show()

import numpy as np
import matplotlib.pyplot as plt

# 酸性物質の放出量モデル
def emission_rate(E0, r, t):
    return E0 * np.exp(r * t)

# 酸性雨のpH変化モデル
def pH_change(pH0, k, E):
    return pH0 - k * E

# パラメータ設定
# 酸性物質のパラメータ
E0 = 100  # 初期放出量 (g)
r = 0.03  # 増加率 (1/year)
time = np.linspace(0, 50, 100)  # 時間 (years)

# 酸性雨のpHのパラメータ
pH0 = 5.6  # 初期pH (中性雨)
k = 0.01   # 酸性物質のpHへの影響係数 (1/g)

# 酸性物質の放出量とpH変化の計算
emission_values = emission_rate(E0, r, time)
pH_values = pH_change(pH0, k, emission_values)

# プロット
plt.figure(figsize=(14, 6))

# 酸性物質の放出量のプロット
plt.subplot(1, 2, 1)
plt.plot(time, emission_values, color='orange')
plt.title('Acidic Substance Emission Over Time')
plt.xlabel('Time (years)')
plt.ylabel('Emission Rate (g)')
plt.grid(True)

# 酸性雨のpH変化のプロット
plt.subplot(1, 2, 2)
plt.plot(time, pH_values, color='blue')
plt.title('pH Change of Acid Rain Over Time')
plt.xlabel('Time (years)')
plt.ylabel('pH')
plt.grid(True)

plt.tight_layout()
plt.show()

import numpy as np
import matplotlib.pyplot as plt

# 内分泌撹乱物質の濃度モデル
def endocrine_disruptor_concentration(C0, r, t):
    return C0 * np.exp(r * t)

# ホルモンレベルへの影響モデル
def hormone_level(H0, k, C):
    return H0 - k * C

# パラメータ設定
# 内分泌撹乱物質のパラメータ
C0 = 10  # 初期濃度 (μg/L)
r = 0.05  # 増加率 (1/year)
time = np.linspace(0, 20, 100)  # 時間 (years)

# ホルモンレベルのパラメータ
H0 = 100  # 初期ホルモンレベル
k = 0.5   # 濃度に対する感度 (1/μg/L)

# 内分泌撹乱物質の濃度とホルモンレベルの計算
concentration_values = endocrine_disruptor_concentration(C0, r, time)
hormone_values = hormone_level(H0, k, concentration_values)

# プロット
plt.figure(figsize=(14, 6))

# 内分泌撹乱物質の濃度のプロット
plt.subplot(1, 2, 1)
plt.plot(time, concentration_values, color='red')
plt.title('Endocrine Disruptor Concentration Over Time')
plt.xlabel('Time (years)')
plt.ylabel('Concentration (μg/L)')
plt.grid(True)

# ホルモンレベルのプロット
plt.subplot(1, 2, 2)
plt.plot(time, hormone_values, color='blue')
plt.title('Hormone Level Over Time')
plt.xlabel('Time (years)')
plt.ylabel('Hormone Level')
plt.grid(True)

plt.tight_layout()
plt.show()



import numpy as np
import matplotlib.pyplot as plt

# 定義
def malthusian_growth(P0, r, t):
    return P0 * np.exp(r * t)

def logistic_growth(P0, K, r, t):
    return K / (1 + ((K - P0) / P0) * np.exp(-r * t))

# パラメータ設定
P0 = 1e6  # 初期人口
r = 0.02  # 成長率
K = 1e8  # 環境収容力(キャパシティ)
t = np.linspace(0, 100, 500)  # 時間範囲

# モデルの計算
population_malthusian = malthusian_growth(P0, r, t)
population_logistic = logistic_growth(P0, K, r, t)

# プロットの準備
fig, ax = plt.subplots(figsize=(12, 8))

# マルサスの成長モデルのプロット
ax.plot(t, population_malthusian, label='Malthusian Growth', color='blue')

# ロジスティック成長モデルのプロット
ax.plot(t, population_logistic, label='Logistic Growth', color='red')

# プロットのカスタマイズ
ax.set_xlabel('Time (years)')
ax.set_ylabel('Population')
ax.set_title('Population Growth Models')
ax.legend()
ax.grid(True)

plt.show()









0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0