高校生物Pythonコード

```
# Function to calculate the actual size of the object in micrometers
def calculate_actual_size(eyepiece_units, calibration_factor):
    """
    Calculate the actual size of the object based on eyepiece units and calibration factor.
    :param eyepiece_units: The number of units seen in the eyepiece micrometer
    :param calibration_factor: The calibration factor between the eyepiece and objective micrometers (in micrometers per eyepiece unit)
    :return: Actual size of the object in micrometers
    """
    return eyepiece_units * calibration_factor

# Example values
eyepiece_units = 10  # Example: Number of divisions on the eyepiece micrometer covering the cell
calibration_factor = 1.5  # Example: 1 eyepiece unit equals 1.5 micrometers (obtained via calibration)

# Calculate actual size
actual_size = calculate_actual_size(eyepiece_units, calibration_factor)
print(f"Actual size of the cell: {actual_size} micrometers")


```
浸透圧・脳圧のグラフ
```


import numpy as np
import matplotlib.pyplot as plt

# Generate data for different polymer systems
# Assume power-law relationships for the scaling behavior
def osmotic_pressure(concentration, scaling_exponent):
    """
    Simulate osmotic pressure using a scaling relationship.
    :param concentration: Polymer concentration (dimensionless or scaled).
    :param scaling_exponent: Scaling exponent for the polymer system.
    :return: Osmotic pressure (dimensionless or scaled).
    """
    return concentration**scaling_exponent

# Polymer concentrations (dimensionless)
concentrations = np.logspace(-2, 1.5, 100)  # Logarithmic scale for concentration

# Simulated osmotic pressure data for different polymer systems
pressure_linear_polystyrene = osmotic_pressure(concentrations, 1.0)  # Linear scaling
pressure_star_polymer = osmotic_pressure(concentrations, 1.2)  # Slightly stronger scaling
pressure_gel_transition = osmotic_pressure(concentrations, 1.3)  # Gelation scaling

# Plot the results
plt.figure(figsize=(8, 6))
plt.plot(concentrations, pressure_linear_polystyrene, label='Linear Polystyrene Solution', color='blue', marker='o', linestyle='--')
plt.plot(concentrations, pressure_star_polymer, label='Star Polymer Solution', color='purple', marker='s', linestyle='--')
plt.plot(concentrations, pressure_gel_transition, label='Gelation Process', color='orange', marker='^', linestyle='--')

# Indicate gelation threshold or transition points (based on visual inspection)
plt.axvline(x=1, color='green', linestyle='-', label='Gelation Transition')

# Customize the plot
plt.xscale('log')  # Logarithmic scale for concentration
plt.yscale('log')  # Logarithmic scale for osmotic pressure
plt.xlabel('Concentration (Dimensionless)', fontsize=14)
plt.ylabel('Osmotic Pressure (Dimensionless)', fontsize=14)
plt.title('Osmotic Pressure vs. Concentration for Polymer Solutions', fontsize=16)
plt.legend()
plt.grid(True)

# Show plot
plt.show()
```
```


import numpy as np
import matplotlib.pyplot as plt

# 時間 (Time)
time = np.linspace(0, 10, 100)  # 0~10秒間の100点 (100 points over 0 to 10 seconds)

# 浸透圧のモデル (Model for osmotic pressure)
# ここではシンプルな指数関数減衰モデル (Here, a simple exponential decay model)
osmotic_pressure = 100 * np.exp(-0.5 * time)

# 脳圧のモデル (Model for intracranial pressure)
# 浸透圧に対する脳圧の遅延反応 (Delayed response to osmotic pressure)
intracranial_pressure = 70 + 10 * np.sin(0.5 * time)

# グラフの作成 (Plotting the graphs)
plt.figure(figsize=(10, 6))

# 浸透圧のプロット (Plotting osmotic pressure)
plt.plot(time, osmotic_pressure, label="Osmotic Pressure (浸透圧)", color='blue', linestyle='-', linewidth=2)

# 脳圧のプロット (Plotting intracranial pressure)
plt.plot(time, intracranial_pressure, label="Intracranial Pressure (脳圧)", color='red', linestyle='--', linewidth=2)

# グラフの装飾 (Adding labels and title)
plt.xlabel("Time (s)", fontsize=12)
plt.ylabel("Pressure (mmHg)", fontsize=12)
plt.title("Osmotic Pressure vs Intracranial Pressure", fontsize=14)
plt.legend(loc="upper right")

# グリッドの追加 (Adding grid)
plt.grid(True)

# グラフの表示 (Show the plot)
plt.show()
```
選択的透過性のグラフ
```
import numpy as np
import matplotlib.pyplot as plt

# Time range for the simulation (in milliseconds)
time = np.linspace(-1, 3, 1000)

# Parameters for action potential phases
resting_potential = -70  # mV
threshold_potential = -55  # mV
peak_potential = 40  # mV
hyperpolarization_potential = -80  # mV

# Create action potential waveform using piecewise functions
def action_potential(t):
    if t < 0:
        return resting_potential  # Resting phase
    elif 0 <= t < 0.5:
        return resting_potential + (threshold_potential - resting_potential) * (t / 0.5)  # Depolarization (towards threshold)
    elif 0.5 <= t < 1:
        return threshold_potential + (peak_potential - threshold_potential) * ((t - 0.5) / 0.5)  # Rapid depolarization to peak
    elif 1 <= t < 1.5:
        return peak_potential - (peak_potential - resting_potential) * ((t - 1) / 0.5)  # Repolarization
    elif 1.5 <= t < 2:
        return resting_potential + (hyperpolarization_potential - resting_potential) * ((t - 1.5) / 0.5)  # Hyperpolarization
    else:
        return resting_potential  # Return to resting potential

# Apply the action potential function to the time array
potential = np.array([action_potential(t) for t in time])

# Plot the action potential
plt.figure(figsize=(8, 6))
plt.plot(time, potential, label='Action Potential', color='black')
plt.axhline(resting_potential, color='blue', linestyle='--', label='Resting Potential')
plt.axhline(threshold_potential, color='orange', linestyle='--', label='Threshold Potential')
plt.axhline(peak_potential, color='red', linestyle='--', label='Peak Potential')
plt.axhline(hyperpolarization_potential, color='green', linestyle='--', label='Hyperpolarization')

# Annotate the graph
plt.title('Simulated Action Potential', fontsize=16)
plt.xlabel('Time (ms)', fontsize=14)
plt.ylabel('Membrane Potential (mV)', fontsize=14)
plt.legend(loc='best')
plt.grid(True)

# Show the plot
plt.show()

```



```
import numpy as np
import matplotlib.pyplot as plt

# 時間 (Time)
time = np.linspace(0, 10, 100)  # 0~10秒間の100点 (100 points over 0 to 10 seconds)

# 物質Aと物質Bの透過モデル (Permeability model for substance A and B)
# Aは速く透過 (Substance A permeates faster)
substance_A = 1 - np.exp(-0.7 * time)  # Aの透過率 (Permeability of A)
# Bは遅く透過 (Substance B permeates slower)
substance_B = 1 - np.exp(-0.3 * time)  # Bの透過率 (Permeability of B)

# グラフの作成 (Plotting the graphs)
plt.figure(figsize=(10, 6))

# 物質Aの透過率のプロット (Plotting permeability for substance A)
plt.plot(time, substance_A, label="Substance A", color='blue', linestyle='-', linewidth=2)

# 物質Bの透過率のプロット (Plotting permeability for substance B)
plt.plot(time, substance_B, label="Substance B", color='green', linestyle='--', linewidth=2)

# グラフの装飾 (Adding labels and title)
plt.xlabel("Time (s)", fontsize=12)
plt.ylabel("Permeability (透過率)", fontsize=12)
plt.title("Selective Permeability of Substances A and B", fontsize=14)
plt.legend(loc="lower right")

# グリッドの追加 (Adding grid)
plt.grid(True)

# グラフの表示 (Show the plot)
plt.show()


```
```

import numpy as np

# Define the function to calculate Respiratory Quotient (RQ)
def calculate_rq(v_co2, v_o2):
    """
    Calculate Respiratory Quotient (RQ) using the ratio of CO2 production to O2 consumption.
    :param v_co2: CO2 produced per unit time (liters/min)
    :param v_o2: O2 consumed per unit time (liters/min)
    :return: RQ (Respiratory Quotient)
    """
    if v_o2 == 0:
        raise ValueError("Oxygen consumption (O2) cannot be zero.")
    return v_co2 / v_o2

# Example values for normal condition and COPD condition
v_co2_normal = 0.2  # Normal condition CO2 production (liters/min)
v_o2_normal = 0.25  # Normal condition O2 consumption (liters/min)

v_co2_copd = 0.15  # COPD condition CO2 production (liters/min)
v_o2_copd = 0.25  # COPD condition O2 consumption (liters/min)

# Calculate the RQ for both normal and COPD conditions
rq_normal = calculate_rq(v_co2_normal, v_o2_normal)
rq_copd = calculate_rq(v_co2_copd, v_o2_copd)

print(f"Normal Condition RQ: {rq_normal:.2f}")
print(f"COPD Condition RQ: {rq_copd:.2f}")

# Use numpy to simulate changes in RQ with varying CO2 and O2 values
# Varying CO2 and O2 to see the range of RQ in different scenarios
v_co2_values = np.linspace(0.1, 0.3, 5)  # Simulating CO2 production from 0.1 to 0.3 liters/min
v_o2_values = np.linspace(0.2, 0.4, 5)  # Simulating O2 consumption from 0.2 to 0.4 liters/min

# Calculate RQ for these values
rq_values = np.array([calculate_rq(co2, o2) for co2, o2 in zip(v_co2_values, v_o2_values)])

print("\nSimulated RQ values for varying CO2 and O2 levels:")
for co2, o2, rq in zip(v_co2_values, v_o2_values, rq_values):
    print(f"CO2: {co2:.2f} L/min, O2: {o2:.2f} L/min, RQ: {rq:.2f}")

# Fat vs Carbohydrate metabolism based on RQ interpretation
def interpret_rq(rq):
    """
    Interpret the RQ value to determine fat or carbohydrate metabolism.
    :param rq: Respiratory Quotient (RQ)
    :return: Metabolic process interpretation
    """
    if rq < 0.7:
        return "Predominantly fat metabolism."
    elif 0.7 <= rq <= 1.0:
        return "Mixed fat and carbohydrate metabolism."
    else:
        return "Predominantly carbohydrate metabolism."

# Interpretation for both normal and COPD conditions
print(f"\nNormal Condition Metabolism: {interpret_rq(rq_normal)}")
print(f"COPD Condition Metabolism: {interpret_rq(rq_copd)}")

```
酵素のグラフ

```
import numpy as np
import matplotlib.pyplot as plt

# Set parameters for Michaelis-Menten equation
V_max = 100  # Maximum reaction velocity
K_m = 5      # Michaelis constant

# Range of substrate concentrations
S = np.linspace(0, 50, 100)  # Substrate concentration from 0 to 50

# Michaelis-Menten equation
v = (V_max * S) / (K_m + S)

# Create the graph
plt.figure(figsize=(8, 6))
plt.plot(S, v, color='blue', label='Reaction Velocity')

# Adding labels and title
plt.xlabel('Substrate Concentration [S]', fontsize=12)
plt.ylabel('Reaction Velocity v', fontsize=12)
plt.title('Michaelis-Menten Enzyme Kinetics', fontsize=14)
plt.legend(loc="upper right")

# Add grid
plt.grid(True)

# Show the plot
plt.show()
```

```
import numpy as np
import matplotlib.pyplot as plt

# Define the Michaelis-Menten equation without inhibition
def michaelis_menten(S, Vmax, Km):
    return (Vmax * S) / (Km + S)

# Define the Michaelis-Menten equation with non-competitive inhibition
def non_competitive_inhibition(S, Vmax, Km, Ki, I):
    return (Vmax * S) / (Km + S + (Km * I / Ki))

# Parameters
Vmax = 100  # Maximum reaction rate
Km = 50     # Michaelis constant (substrate concentration at half Vmax)
Ki = 20     # Inhibition constant (strength of the inhibitor)
I = 1       # Concentration of the inhibitor

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

# Calculate reaction rates without and with inhibitor
reaction_rate_no_inhibitor = michaelis_menten(S, Vmax, Km)
reaction_rate_with_inhibitor = non_competitive_inhibition(S, Vmax, Km, Ki, I)

# Plot the results
plt.figure(figsize=(10, 6))
plt.plot(S, reaction_rate_no_inhibitor, label='No Inhibitor', color='blue', linewidth=2)
plt.plot(S, reaction_rate_with_inhibitor, label='With Non-Competitive Inhibitor', color='red', linestyle='--', linewidth=2)
plt.title('Enzyme Kinetics: Non-Competitive Inhibition')
plt.xlabel('Substrate Concentration [S]')
plt.ylabel('Reaction Rate')
plt.legend()
plt.grid(True)
plt.show()

```


```

import numpy as np
import matplotlib.pyplot as plt

# Set parameters for Michaelis-Menten equation
V_max = 100  # Maximum reaction velocity
K_m = 5      # Michaelis constant
K_i = 10     # Inhibition constant

# Range of substrate concentrations
S = np.linspace(0, 50, 100)  # Substrate concentration from 0 to 50

# Define different inhibitor concentrations
I_values = [0, 5, 10, 20]  # Inhibitor concentrations

# Create the graph
plt.figure(figsize=(8, 6))

for I in I_values:
    # Non-competitive inhibition Michaelis-Menten equation
    v = (V_max / (1 + I / K_i)) * S / (K_m + S)
    # Plot for each inhibitor concentration
    plt.plot(S, v, label=f'Inhibitor [I] = {I} mM')

# Adding labels and title
plt.xlabel('Substrate Concentration [S]', fontsize=12)
plt.ylabel('Reaction Velocity v', fontsize=12)
plt.title('Non-competitive Inhibition', fontsize=14)
plt.legend(loc="lower right")

# Add grid
plt.grid(True)

# Show the plot
plt.show()

```


呼吸の計算
```
# Define a function to calculate respiratory quotient (RQ)
def calculate_rq(o2_consumed, co2_released):
    """
    Function to calculate the respiratory quotient (RQ).
    :param o2_consumed: Amount of O2 consumed (mol or L)
    :param co2_released: Amount of CO2 released (mol or L)
    :return: Respiratory quotient (RQ)
    """
    rq = co2_released / o2_consumed
    return rq

# Data for different substances (O2 consumed, CO2 released in mol)
substrates = {
    "Glucose (Carbohydrate)": {"o2_consumed": 6, "co2_released": 6},  # C6H12O6 + 6O2 → 6CO2 + 6H2O
    "Amino Acids (Protein)": {"o2_consumed": 15, "co2_released": 12},  # 2C6H13O2N + 15O2 → 12CO2 + 10H2O + 2NH3
    "Fat (Lipid)": {"o2_consumed": 163, "co2_released": 114}  # 2C57H110O6 + 163O2 → 114CO2 + 110H2O
}

# Calculate and display the RQ for each substrate
for substrate, values in substrates.items():
    rq = calculate_rq(values["o2_consumed"], values["co2_released"])
    print(f"Respiratory Quotient for {substrate}: {rq:.2f}")

# Plotting the data
import matplotlib.pyplot as plt

# Substrate names and RQ values
substrate_names = list(substrates.keys())
rq_values = [calculate_rq(values["o2_consumed"], values["co2_released"]) for values in substrates.values()]

# Plot the RQ values
plt.figure(figsize=(10, 6))
plt.bar(substrate_names, rq_values, color=['blue', 'green', 'red'])
plt.title('Respiratory Quotient for Different Metabolic Substrates')
plt.xlabel('Substrate')
plt.ylabel('Respiratory Quotient (RQ)')
plt.ylim(0, 1.2)
plt.grid(True)
plt.show()


```


```

def calculate_ventilation(f, Vt): 
    # 呼吸数(f)と1回換気量(Vt)から換気量(V)を計算する 
    ventilation = f * Vt 
    return ventilation

# 呼吸数 (回/分)
f = 15  # 例: 1分間に15回呼吸する

# 1回換気量 (リットル)
Vt = 0.5  # 例: 1回の呼吸で0.5リットルの空気を吸い込む

# 換気量を計算
ventilation = calculate_ventilation(f, Vt)

print(f"換気量は {ventilation} リットル/分です")

```
見かけの光合成のグラフと計算
```
import numpy as np
import matplotlib.pyplot as plt

# パラメータの設定 (Set parameters)
P_max = 20    # 最大光合成速度 (Maximum photosynthesis rate)
alpha = 0.1   # 光合成効率 (Photosynthesis efficiency)
R = 5         # 呼吸速度 (Respiration rate)

# 光強度の範囲 (Range of light intensity)
I = np.linspace(0, 100, 100)  # 光強度 (Light intensity from 0 to 100)

# 見かけの光合成速度の計算 (Calculate apparent photosynthesis rate)
v = P_max * (1 - np.exp(-alpha * I)) - R

# グラフの作成 (Create the graph)
plt.figure(figsize=(8, 6))
plt.plot(I, v, color='green', label='Apparent Photosynthesis Rate')

# グラフの装飾 (Adding labels and title)
plt.xlabel('Light Intensity [I] ', fontsize=12)
plt.ylabel('Apparent Photosynthesis Rate [v] ', fontsize=12)
plt.title('Apparent Photosynthesis Rate vs Light Intensity', fontsize=14)
plt.legend(loc="lower right")

# グリッドの追加 (Add grid)
plt.grid(True)

# グラフの表示 (Show the plot)
plt.show()


```


```
import numpy as np
import matplotlib.pyplot as plt

# Function to model the relationship between light intensity and photosynthesis rate
def photosynthesis_rate(light_intensity, P_max, I_sat, R_rate):
    """
    Calculate the photosynthesis rate based on light intensity.
    :param light_intensity: Light intensity (arbitrary units)
    :param P_max: Maximum photosynthesis rate
    :param I_sat: Saturation point for light intensity
    :param R_rate: Respiration rate (negative CO2 absorption)
    :return: Photosynthesis rate
    """
    # Photosynthesis increases linearly with light intensity until saturation
    return np.minimum(P_max, P_max * (light_intensity / I_sat)) - R_rate

# Parameters
P_max = 10  # Maximum photosynthesis rate (arbitrary units)
I_sat = 50  # Saturation point of light intensity (arbitrary units)
R_rate = 2  # Respiration rate (CO2 release when light is zero)

# Light intensity range
light_intensities = np.linspace(0, 100, 500)

# Calculate photosynthesis rate for each light intensity
photosynthesis_rates = photosynthesis_rate(light_intensities, P_max, I_sat, R_rate)

# Plot the relationship
plt.figure(figsize=(8, 6))
plt.plot(light_intensities, photosynthesis_rates, label="Photosynthesis rate", color="green")
plt.axhline(0, color='black', linestyle='--', label="CO2 absorption = 0")
plt.axvline(I_sat, color='blue', linestyle='--', label="Saturation point (light intensity)")
plt.axhline(-R_rate, color='red', linestyle='--', label="Respiration rate")

# Add annotations for light compensation point and saturation point
plt.text(5, -R_rate - 0.5, "Light compensation point", verticalalignment='center', color='blue')
plt.text(I_sat + 5, P_max / 2, "Light saturation point", verticalalignment='center', color='blue')

# Labels and title
plt.title('Photosynthesis Rate vs Light Intensity', fontsize=16)
plt.xlabel('Light Intensity (arbitrary units)', fontsize=14)
plt.ylabel('Photosynthesis Rate (arbitrary units)', fontsize=14)
plt.legend()
plt.grid(True)

# Show plot
plt.show()



```
カルピン・ベンソン回路のグラフ

```
import numpy as np
import matplotlib.pyplot as plt

# Set parameters
CO2_absorption_rate = 0.1  # Rate of CO2 absorption
ATP_usage_rate = 0.05      # Rate of ATP usage
NADPH_usage_rate = 0.04    # Rate of NADPH usage

# Time range for simulation
time = np.linspace(0, 100, 200)  # Time from 0 to 100 seconds

# Concentration changes over time
CO2_concentration = 100 * np.exp(-CO2_absorption_rate * time)  # CO2 concentration decrease
ATP_concentration = 100 * np.exp(-ATP_usage_rate * time)       # ATP concentration decrease
NADPH_concentration = 100 * np.exp(-NADPH_usage_rate * time)   # NADPH concentration decrease

# Increase in products like G3P
G3P_concentration = 100 * (1 - np.exp(-CO2_absorption_rate * time))  # G3P concentration increase

# Create the graph
plt.figure(figsize=(10, 6))

# CO2, ATP, NADPH, and G3P concentrations over time
plt.plot(time, CO2_concentration, label='CO2 Concentration', color='green')
plt.plot(time, ATP_concentration, label='ATP Concentration', color='blue')
plt.plot(time, NADPH_concentration, label='NADPH Concentration', color='orange')
plt.plot(time, G3P_concentration, label='G3P Concentration', color='red')

# Adding labels and title
plt.xlabel('Time (seconds)', fontsize=12)
plt.ylabel('Concentration', fontsize=12)
plt.title('Calvin-Benson Cycle: Concentrations Over Time', fontsize=14)
plt.legend(loc="best")

# Add grid
plt.grid(True)

# Show the plot
plt.show()


```

興奮の伝導

```



import numpy as np
import matplotlib.pyplot as plt

# Time range
time = np.linspace(0, 10, 1000)  # 0 to 10 milliseconds

# Action potential model (Depolarization, Repolarization, Hyperpolarization)
def action_potential(t):
    if 1 < t < 3:
        return 30  # Depolarization phase
    elif 3 <= t < 7:
        return -70 - (t - 3) * 10  # Repolarization phase
    elif 7 <= t < 9:
        return -90  # Hyperpolarization phase
    else:
        return -70  # Resting potential

# Generating action potential data
voltage = np.array([action_potential(t) for t in time])

# Create the graph
plt.figure(figsize=(10, 6))
plt.plot(time, voltage, color='blue', label='Membrane Potential')

# Adding labels and title
plt.xlabel('Time (ms)', fontsize=12)
plt.ylabel('Membrane Potential (mV)', fontsize=12)
plt.title('Action Potential', fontsize=14)
plt.legend(loc="best")

# Add grid
plt.grid(True)

# Show the plot
plt.show()


```

刺激の大きさと筋収縮のグラフ

```
import numpy as np
import matplotlib.pyplot as plt

# Define parameters for muscle contraction model
max_contraction = 100  # Maximum muscle contraction
stimulus_threshold = 5  # Stimulus intensity at which contraction starts
steepness = 1  # Controls the steepness of the contraction curve

# Range of stimulus intensity (from 0 to 20 arbitrary units)
stimulus_intensity = np.linspace(0, 20, 100)

# Sigmoid-like function to model muscle contraction response
muscle_contraction = max_contraction / (1 + np.exp(-steepness * (stimulus_intensity - stimulus_threshold)))

# Create the graph
plt.figure(figsize=(8, 6))
plt.plot(stimulus_intensity, muscle_contraction, color='red', label='Muscle Contraction')

# Adding labels and title
plt.xlabel('Stimulus Intensity', fontsize=12)
plt.ylabel('Muscle Contraction (%)', fontsize=12)
plt.title('Stimulus Intensity vs Muscle Contraction', fontsize=14)
plt.legend(loc="lower right")

# Add grid
plt.grid(True)

# Show the plot
plt.show()


```
```
import numpy as np
import matplotlib.pyplot as plt

# Time range for the simulation (in milliseconds)
time = np.linspace(0, 200, 1000)  # Simulating from 0 to 200 ms

# Function to simulate a single muscle twitch response
def single_twitch(t, t_peak=50, duration=30, amplitude=1):
    """
    Simulates a single twitch contraction.
    :param t: Time points (ms)
    :param t_peak: Time to reach the peak of contraction (ms)
    :param duration: Duration of contraction (ms)
    :param amplitude: Maximum amplitude of contraction
    :return: Contraction amplitude over time
    """
    return amplitude * np.exp(-(t - t_peak)**2 / (2 * (duration / 3)**2))

# Simulate multiple twitch responses for different stimulation frequencies
def repeated_twitch(t, frequency, amplitude=1):
    """
    Simulates repeated twitches based on stimulation frequency.
    :param t: Time points (ms)
    :param frequency: Stimulation frequency (Hz)
    :param amplitude: Maximum amplitude of each twitch
    :return: Summed twitch response over time
    """
    twitch_sum = np.zeros_like(t)
    interval = 1000 / frequency  # Convert frequency (Hz) to time interval (ms)
    
    # Add a twitch response at each interval
    for i in range(0, len(t), int(interval * 5)):  # Multiply by 5 to get a clearer contraction series
        twitch_sum += single_twitch(t - i, t_peak=i)
    return np.clip(twitch_sum, 0, None)  # Prevent negative values

# Parameters for muscle responses
twitch_amplitude = 1.0
frequencies = [2, 10, 50]  # Frequencies for single twitch, incomplete tetanus, and complete tetanus

# Plot each type of muscle response
plt.figure(figsize=(10, 6))

for freq, label in zip(frequencies, ['Single Twitch', 'Incomplete Tetanus', 'Complete Tetanus']):
    contraction = repeated_twitch(time, freq, amplitude=twitch_amplitude)
    plt.plot(time, contraction, label=label)

# Customize the plot
plt.title('Muscle Contraction: Twitch and Tetanus Responses', fontsize=16)
plt.xlabel('Time (ms)', fontsize=14)
plt.ylabel('Muscle Tension (Arbitrary Units)', fontsize=14)
plt.axhline(0, color='black', linestyle='--')
plt.legend(loc='best')
plt.grid(True)

# Show the plot
plt.show()


```
筋収縮の張力のグラフ

```
import numpy as np
import matplotlib.pyplot as plt

# Define parameters for muscle tension model
optimal_length = 1.0  # The optimal muscle length for maximal tension
max_tension = 100  # Maximum tension generated by the muscle
stretch_factor = 0.5  # Controls how quickly tension drops off as contraction deviates from optimal length

# Range of muscle length (representing contraction and stretching)
muscle_length = np.linspace(0.5, 1.5, 100)  # Values from 0.5 to 1.5 represent contraction/stretching

# Parabolic function to model tension based on muscle length
# Tension is maximal at the optimal length, and decreases for lengths shorter or longer than optimal
muscle_tension = max_tension * np.exp(-((muscle_length - optimal_length)**2) / (2 * stretch_factor**2))

# Create the graph
plt.figure(figsize=(8, 6))
plt.plot(muscle_length, muscle_tension, color='blue', label='Muscle Tension')

# Adding labels and title
plt.xlabel('Muscle Length (normalized)', fontsize=12)
plt.ylabel('Muscle Tension (force)', fontsize=12)
plt.title('Muscle Length vs Tension', fontsize=14)
plt.legend(loc="upper right")

# Add grid
plt.grid(True)

# Show the plot
plt.show()

```



筋収縮のエネルギー源の計算
```
import numpy as np
import matplotlib.pyplot as plt

# Time range for simulation (in seconds)
time = np.linspace(0, 120, 1000)  # 0 to 120 seconds (2 minutes)

# Energy sources:
# ATP, Creatine Phosphate, Anaerobic Glycolysis, Aerobic Respiration

# Define parameters for how each energy source contributes over time
ATP_duration = 2  # ATP provides energy for the first 2 seconds
CP_duration = 10  # Creatine phosphate provides energy for the first 10 seconds
anaerobic_peak = 20  # Anaerobic glycolysis peaks at around 20 seconds
aerobic_start = 30  # Aerobic respiration takes over after 30 seconds

# ATP contribution (quickly drops off after 2 seconds)
ATP_contribution = np.where(time <= ATP_duration, 1 - (time / ATP_duration), 0)

# Creatine Phosphate contribution (peaks at 10 seconds, then drops)
CP_contribution = np.where(time <= CP_duration, 1 - (time / CP_duration), 0)

# Anaerobic Glycolysis contribution (peaks at 20 seconds and drops off)
anaerobic_contribution = np.exp(-0.05 * (time - anaerobic_peak)**2)

# Aerobic Respiration contribution (starts slow, then gradually increases)
aerobic_contribution = 1 / (1 + np.exp(-(time - aerobic_start) / 10))

# Normalize the contributions (for visualization purposes)
total_contribution = ATP_contribution + CP_contribution + anaerobic_contribution + aerobic_contribution
ATP_contribution /= total_contribution
CP_contribution /= total_contribution
anaerobic_contribution /= total_contribution
aerobic_contribution /= total_contribution

# Create the graph
plt.figure(figsize=(10, 6))
plt.plot(time, ATP_contribution, label='ATP', color='blue')
plt.plot(time, CP_contribution, label='Creatine Phosphate', color='green')
plt.plot(time, anaerobic_contribution, label='Anaerobic Glycolysis', color='red')
plt.plot(time, aerobic_contribution, label='Aerobic Respiration', color='orange')

# Adding labels and title
plt.xlabel('Time (seconds)', fontsize=12)
plt.ylabel('Energy Contribution (relative)', fontsize=12)
plt.title('Energy Sources for Muscle Contraction Over Time', fontsize=14)
plt.legend(loc="best")

# Add grid
plt.grid(True)

# Show the plot
plt.show()

```

尿生成の計算
尿生成のグラフ


```
import numpy as np
import matplotlib.pyplot as plt

# Time range (in minutes)
time = np.linspace(0, 120, 500)  # 0 to 120 minutes

# Define parameters (rates in mL/min)
filtration_rate = 120  # Glomerular Filtration Rate (GFR) in mL/min
reabsorption_rate = 118  # Reabsorption rate in mL/min
secretion_rate = 1  # Secretion rate in mL/min

# Urine formation calculation over time
urine_volume = (filtration_rate - reabsorption_rate + secretion_rate) * time

# Create the graph
plt.figure(figsize=(8, 6))
plt.plot(time, urine_volume, color='blue', label='Urine Volume')

# Adding labels and title
plt.xlabel('Time (minutes)', fontsize=12)
plt.ylabel('Urine Volume (mL)', fontsize=12)
plt.title('Urine Formation Over Time', fontsize=14)
plt.legend(loc="upper left")

# Add grid
plt.grid(True)

# Show the plot
plt.show()


```
免疫のグラフ




```

import numpy as np
import matplotlib.pyplot as plt

# Time range (days)
time = np.linspace(0, 50, 500)  # 0 to 50 days

# Parameters for immune response
primary_response_peak = 20   # Time (days) when primary immune response peaks
secondary_response_peak = 35 # Time (days) when secondary immune response peaks
primary_strength = 1         # Strength of the primary immune response
secondary_strength = 4       # Strength of the secondary immune response
response_duration = 5        # Duration over which the immune response rises and falls

# Immune response model (Gaussian-like function for antibody levels)
def immune_response(t, peak_time, strength, duration):
    return strength * np.exp(-((t - peak_time)**2) / (2 * duration**2))

# Calculate primary and secondary immune responses
primary_response = immune_response(time, primary_response_peak, primary_strength, response_duration)
secondary_response = immune_response(time, secondary_response_peak, secondary_strength, response_duration)

# Total immune response is the sum of the primary and secondary responses
total_response = primary_response + secondary_response

# Plot the immune responses
plt.figure(figsize=(10, 6))
plt.plot(time, primary_response, label='Primary Response', color='blue')
plt.plot(time, secondary_response, label='Secondary Response', color='green')
plt.plot(time, total_response, label='Total Immune Response', color='red', linestyle='--')

# Adding labels and title
plt.xlabel('Time (days)', fontsize=12)
plt.ylabel('Antibody Level', fontsize=12)
plt.title('Immune Response: Primary and Secondary', fontsize=14)
plt.legend(loc="upper right")

# Add grid
plt.grid(True)

# Show the plot
plt.show()


```



```
import numpy as np
import matplotlib.pyplot as plt

# Oxygen dissociation curve (sigmoid shape function)
def oxygen_dissociation_curve(pO2, P50, n):
    """
    Function to calculate the hemoglobin saturation as a function of pO2.
    :param pO2: Partial pressure of oxygen (mmHg)
    :param P50: The pO2 at which hemoglobin is 50% saturated
    :param n: Hill coefficient (affinity)
    :return: Oxygen saturation percentage
    """
    return (pO2**n) / (P50**n + pO2**n)

# Parameters
P50_normal = 26  # pO2 at which hemoglobin is 50% saturated under normal conditions
P50_shift = 30   # pO2 at 50% saturation with a rightward shift (due to high CO2 or low pH)
n = 2.8          # Hill coefficient for the sigmoid shape

# Range of pO2 (oxygen concentration)
pO2 = np.linspace(0, 100, 500)

# Calculate oxygen saturation for normal and shifted conditions
saturation_normal = oxygen_dissociation_curve(pO2, P50_normal, n)
saturation_shift = oxygen_dissociation_curve(pO2, P50_shift, n)

# Plot the oxygen dissociation curves
plt.figure(figsize=(10, 6))
plt.plot(pO2, saturation_normal * 100, label='Normal CO2 (P50 = 26)', color='blue', linewidth=2)
plt.plot(pO2, saturation_shift * 100, label='Increased CO2 (P50 = 30)', color='red', linestyle='--', linewidth=2)
plt.title('Oxygen Dissociation Curve (Effect of CO2 on Hemoglobin Affinity)')
plt.xlabel('Oxygen Partial Pressure (pO2) [mmHg]')
plt.ylabel('Hemoglobin Saturation [%]')
plt.legend()
plt.grid(True)
plt.show()


```



```

import numpy as np
import matplotlib.pyplot as plt

# Function to calculate reabsorbed glucose based on blood glucose level
def glucose_reabsorption(blood_glucose, threshold, max_reabsorption):
    """
    Function to calculate urinary glucose levels based on blood glucose concentration.
    :param blood_glucose: Glucose concentration in the blood (mg/dL)
    :param threshold: Renal threshold for glucose reabsorption (mg/dL)
    :param max_reabsorption: Maximum reabsorption capacity of the kidneys (mg/dL)
    :return: Urinary glucose concentration (mg/dL)
    """
    reabsorbed_glucose = np.minimum(blood_glucose, max_reabsorption)
    urinary_glucose = np.maximum(0, blood_glucose - reabsorbed_glucose)
    return urinary_glucose

# Parameters
threshold = 180  # Renal threshold for glucose (mg/dL)
max_reabsorption = 300  # Maximum glucose reabsorption capacity (mg/dL)

# Blood glucose levels (range from 0 to 600 mg/dL)
blood_glucose = np.linspace(0, 600, 100)

# Urinary glucose calculation
urinary_glucose = glucose_reabsorption(blood_glucose, threshold, max_reabsorption)

# Plot the blood glucose and urinary glucose levels
plt.figure(figsize=(10, 6))

# Blood glucose plot (identity line for comparison)
plt.plot(blood_glucose, blood_glucose, label='Blood Glucose Level', color='black', linestyle='-', linewidth=2)

# Urinary glucose plot (shows when glucose starts to appear in urine)
plt.plot(blood_glucose, urinary_glucose, label='Urinary Glucose Level', color='red', linestyle='--', linewidth=2)

# Labels and title
plt.title('Blood Glucose vs Urinary Glucose Levels')
plt.xlabel('Blood Glucose Concentration (mg/dL)')
plt.ylabel('Glucose Amount (mg/dL)')
plt.legend()
plt.grid(True)

# Show the plot
plt.show()


```


```
import numpy as np
import matplotlib.pyplot as plt

# Function to model the relationship between distance and waggle dance loops
def waggle_dance_loops(distance, max_loops, decay_rate):
    """
    Function to calculate the number of waggle dance loops as a function of distance.
    :param distance: Distance to the food source (in meters)
    :param max_loops: Maximum number of waggle dance loops when distance is minimal
    :param decay_rate: Rate at which the number of loops decays as distance increases
    :return: Number of waggle dance loops
    """
    return max_loops * np.exp(-decay_rate * distance)

# Parameters
max_loops = 8  # Maximum number of waggle dance loops at minimal distance
decay_rate = 0.05  # Rate at which loops decay with increasing distance

# Generate distances (0 to 60 meters)
distances = np.linspace(0, 60, 100)

# Calculate the number of waggle dance loops for each distance
waggle_loops = waggle_dance_loops(distances, max_loops, decay_rate)

# Plot the results
plt.figure(figsize=(10, 6))
plt.plot(distances, waggle_loops, label='Waggle Dance Loops', color='green', linestyle='-', linewidth=2)
plt.title('Waggle Dance Loops vs Distance to Food Source')
plt.xlabel('Distance to Food Source (meters)')
plt.ylabel('Number of Waggle Dance Loops')
plt.grid(True)
plt.legend()
plt.show()



```



```
import numpy as np
import matplotlib.pyplot as plt

# Define the functions for Gross Primary Production (GPP) and Respiration (R)
def gross_primary_production(t):
    """Simulates gross primary production over time"""
    return 100 * (1 - np.exp(-0.1 * t))  # GPP rises and plateaus over time

def respiration(t):
    """Simulates respiration over time"""
    return 20 + 0.2 * t  # Respiration increases steadily over time

# Time range (0 to 100 units of time)
time = np.linspace(0, 100, 500)

# Calculate GPP, respiration, and NPP (GPP - respiration)
gpp = gross_primary_production(time)
resp = respiration(time)
npp = gpp - resp

# Plot the results
plt.figure(figsize=(10, 6))

# Plot GPP
plt.plot(time, gpp, label='Gross Primary Production (GPP)', color='black', linestyle='-', linewidth=2)

# Plot Respiration (R)
plt.plot(time, resp, label='Respiration (R)', color='red', linestyle='-', linewidth=2)

# Plot Net Primary Production (NPP)
plt.fill_between(time, 0, npp, where=(npp > 0), color='green', alpha=0.3, label='Net Primary Production (NPP = GPP - R)')

# Labels and title
plt.title('Gross and Net Primary Production over Time')
plt.xlabel('Time')
plt.ylabel('Relative Amount')
plt.legend()
plt.grid(True)

# Show the plot
plt.show()


```

```
import numpy as np
import matplotlib.pyplot as plt

# Hill equation for oxygen saturation (Saturation as a function of partial pressure of oxygen PaO2)
def oxygen_saturation(PaO2, P50=26, n=2.7):
    """
    Calculate oxygen saturation using the Hill equation.
    :param PaO2: Partial pressure of oxygen (PaO2 in Torr)
    :param P50: Partial pressure at which hemoglobin is 50% saturated (default 26 Torr)
    :param n: Hill coefficient (default 2.7)
    :return: Oxygen saturation percentage
    """
    return 100 * (PaO2**n / (P50**n + PaO2**n))

# Generate PaO2 values (0 to 100 Torr)
PaO2_values = np.linspace(0, 100, 500)

# Calculate oxygen saturation for normal conditions (lungs) and tissue conditions
saturation_lungs = oxygen_saturation(PaO2_values, P50=26, n=2.7)  # Typical P50 for normal lung environment
saturation_tissue = oxygen_saturation(PaO2_values, P50=40, n=2.7)  # Higher P50 indicating oxygen release in tissues

# Plot the oxygen dissociation curves
plt.figure(figsize=(8, 6))

# Plot lung and tissue curves
plt.plot(PaO2_values, saturation_lungs, label='Lung Environment', color='blue')
plt.plot(PaO2_values, saturation_tissue, label='Tissue Environment', color='red')

# Customize plot
plt.title('Oxygen Dissociation Curve', fontsize=16)
plt.xlabel('PaO2 (Torr)', fontsize=14)
plt.ylabel('Oxygen Saturation (%)', fontsize=14)
plt.ylim(0, 100)
plt.grid(True)

# Adding labels for important points
plt.axhline(50, color='black', linestyle='--', label='50% Saturation')
plt.axvline(26, color='blue', linestyle='--', label='P50 in Lungs (26 Torr)')
plt.axvline(40, color='red', linestyle='--', label='P50 in Tissue (40 Torr)')

# Show legend
plt.legend()

# Display the plot
plt.show()


```
```

import numpy as np
import matplotlib.pyplot as plt

# Data for broadleaf plant structure (relative height and biomass distribution)
height_broadleaf = np.linspace(0, 100, 10)  # Height in cm
biomass_broadleaf = np.array([0, 0, 5, 10, 15, 20, 25, 30, 40, 50])  # Biomass distribution in g

# Data for grass structure (relative height and biomass distribution)
height_grass = np.linspace(0, 100, 10)  # Height in cm
biomass_grass = np.array([5, 10, 15, 20, 25, 25, 20, 15, 10, 5])  # Biomass distribution in g

# Normalize the biomass data to get percentage (relative contribution at each height)
biomass_broadleaf_relative = (biomass_broadleaf / biomass_broadleaf.sum()) * 100
biomass_grass_relative = (biomass_grass / biomass_grass.sum()) * 100

# Create the plot
fig, axes = plt.subplots(1, 2, figsize=(12, 6))

# Plot for broadleaf plant
axes[0].barh(height_broadleaf, biomass_broadleaf_relative, color='green', alpha=0.6, label="Broadleaf Plant Biomass")
axes[0].invert_yaxis()
axes[0].set_title('Broadleaf Plant Production Structure')
axes[0].set_xlabel('Relative Biomass [%]')
axes[0].set_ylabel('Height [cm]')
axes[0].grid(True)

# Plot for grass plant
axes[1].barh(height_grass, biomass_grass_relative, color='brown', alpha=0.6, label="Grass Biomass")
axes[1].invert_yaxis()
axes[1].set_title('Grass Plant Production Structure')
axes[1].set_xlabel('Relative Biomass [%]')
axes[1].grid(True)

# Show the plots
plt.tight_layout()
plt.show()
```