Here is the plot of the surface liquid level position (in meters) versus time (in seconds). This simulation models the oscillations of the liquid level relative to the surface of the bath, considering damping and gravitational effects.
# Redefine parameters to simulate the surface liquid level
g = 9.8 # Acceleration due to gravity (m/s^2)
h = 0.102 # Submerged depth of straw (m)
b = 0.05 # Damping coefficient
y0 = 0.002 # Initial position relative to the bath surface (m)
y_dot0 = 0.0 # Initial velocity (m/s)
# Define the differential equation for surface liquid level position
def surface_model(y, t, g, h, b):
y, y_dot = y # Unpack surface position and its time derivative (velocity)
dydt = y_dot # First derivative (velocity)
dydotdt = - (g / h) * y - b * y_dot # Second derivative (acceleration)
return [dydt, dydotdt]
# Time points where solution is computed
t = np.linspace(0, 10, 1000) # Time range (0 to 10 seconds)
# Initial conditions for surface liquid level
y0 = [y0, y_dot0]
# Solve the ODE for surface liquid level
sol_surface = odeint(surface_model, y0, t, args=(g, h, b))
# Extract surface liquid level position y(t) from the solution
y = sol_surface[:, 0]
# Plot the results for surface liquid level
plt.figure(figsize=(10, 6))
plt.plot(t, y, label='Surface Liquid Level Position (m)')
plt.xlabel('Time (s)')
plt.ylabel('Surface Liquid Level Position (m)')
plt.title('Oscillations of Surface Liquid Level (y vs Time)')
plt.grid(True)
plt.legend()
plt.show()
Here is the plot showing the oscillations of the surface liquid level with increased damping. As expected, the larger damping coefficient reduces the oscillation amplitude and causes the system to settle more quickly.
# Increase the damping coefficient for more damping
b_heavy_damping = 0.5 # Increased damping coefficient
# Solve the ODE for surface liquid level with heavier damping
sol_surface_damped = odeint(surface_model, y0, t, args=(g, h, b_heavy_damping))
# Extract surface liquid level position y(t) from the solution
y_damped = sol_surface_damped[:, 0]
# Plot the results for surface liquid level with increased damping
plt.figure(figsize=(10, 6))
plt.plot(t, y_damped, label='Surface Liquid Level Position with Heavy Damping (m)', color='red')
plt.xlabel('Time (s)')
plt.ylabel('Surface Liquid Level Position (m)')
plt.title('Oscillations of Surface Liquid Level (Heavy Damping, y vs Time)')
plt.grid(True)
plt.legend()
plt.show()
We can simulate the oscillations using different fluids by adjusting the fluid properties like density and viscosity, which impact the damping and oscillatory behavior. For this simulation, we will focus on how the fluid density affects the system, assuming the fluid viscosity influences the damping coefficient.
Let me modify the simulation to show how different fluids, such as water, oil, and glycerin, would behave. I'll adjust the damping and fluid density for each fluid type.
Water: Density = 1000 kg/m³, Moderate damping
Oil: Density = 900 kg/m³, Higher damping
Glycerin: Density = 1260 kg/m³, Significantly higher damping
Here is the plot showing the oscillations of the surface liquid level for different fluids: water, oil, and glycerin. As expected:
Water has the least damping, allowing more prolonged oscillations.
Oil exhibits higher damping, leading to faster decay of oscillations.
Glycerin has the highest damping, causing the oscillations to settle very quickly
# Define different fluid densities (kg/m^3) and damping factors for each fluid
fluids = {
'Water': {'density': 1000, 'damping': 0.05}, # Water: typical damping
'Oil': {'density': 900, 'damping': 0.15}, # Oil: more viscous, higher damping
'Glycerin': {'density': 1260, 'damping': 0.4} # Glycerin: very viscous, much higher damping
}
# Prepare to plot all three fluids
plt.figure(figsize=(10, 6))
# Time points where solution is computed
t = np.linspace(0, 10, 1000)
# Simulate for each fluid
for fluid, properties in fluids.items():
damping = properties['damping']
# Solve the ODE for each fluid's surface liquid level
sol_fluid = odeint(surface_model, y0, t, args=(g, h, damping))
# Extract the surface liquid level for each fluid
y_fluid = sol_fluid[:, 0]
# Plot the results for each fluid
plt.plot(t, y_fluid, label=f'{fluid} (Damping: {damping})')
# Customize the plot
plt.xlabel('Time (s)')
plt.ylabel('Surface Liquid Level Position (m)')
plt.title('Oscillations of Surface Liquid Level for Different Fluids')
plt.grid(True)
plt.legend()
plt.show()
Let's simulate the oscillations for water while adjusting its viscosity and density as a function of temperature. For this, we will consider the following:
For water, viscosity decreases approximately exponentially with temperature:
Where:
μ0 = 0.001 Pa·s (viscosity at 20°C)
k ≈ 0.02 1/°C (empirical constant for water)
Density decreases linearly with temperature:
Where:
ρ0 = 1000 kg/m³ (density at 0°C)
α = 0.000214 1/°C (thermal expansion coefficient for water)
We'll simulate the oscillations for a temperature range, say from 10°C to 50°C, and observe how the oscillations change with temperature. The damping coefficient will depend on the viscosity, and the oscillation frequency will be influenced by the density.
Here is the plot showing the oscillations of the surface liquid level for water at different temperatures (ranging from 10°C to 50°C). As the temperature increases, the viscosity decreases, leading to less damping and more pronounced oscillations. Lower temperatures, where the viscosity is higher, result in quicker damping of the oscillations.
This demonstrates how temperature impacts the fluid's behavior through changes in viscosity and density.
# Constants for water
mu_0 = 0.001 # Viscosity at 20°C (Pa·s)
k = 0.02 # Temperature dependence of viscosity (1/°C)
rho_0 = 1000 # Density at 0°C (kg/m³)
alpha = 0.000214 # Thermal expansion coefficient (1/°C)
# Define a temperature range
temperatures = np.linspace(10, 50, 5) # Temperatures from 10°C to 50°C
# Time points for simulation
t = np.linspace(0, 10, 1000) # Time range (0 to 10 seconds)
# Prepare to plot oscillations for different temperatures
plt.figure(figsize=(10, 6))
# Loop over each temperature to simulate
for T in temperatures:
# Calculate the viscosity and density at this temperature
mu_T = mu_0 * np.exp(-k * T)
rho_T = rho_0 * (1 - alpha * T)
# Adjust damping coefficient as a function of viscosity (simplified relation)
b_T = 0.05 * (mu_T / mu_0) # Adjust damping based on viscosity
# Solve the ODE for surface liquid level at this temperature
sol_temp = odeint(surface_model, y0, t, args=(g, h, b_T))
# Extract surface liquid level position y(t)
y_temp = sol_temp[:, 0]
# Plot the results for this temperature
plt.plot(t, y_temp, label=f'Temperature {T}°C')
# Customize the plot
plt.xlabel('Time (s)')
plt.ylabel('Surface Liquid Level Position (m)')
plt.title('Oscillations of Surface Liquid Level for Water at Different Temperatures')
plt.grid(True)
plt.legend()
plt.show()