Bisection
Bisection
Problem 1.
For a feedback control system, a valve is controlling the water flow rate going
into a tank. The set point is for the flow rate to be 10 L/min. The system is nonlinear;
that is, the valve opening relationship to the flow rate is not a linear equation. We can
measure the actual flow rate, y, but we can't measure the water level within the tank
directly. We wish to determine the valve opening, u, such that the desired flow rate, y =
10 L/min occurs by using the bisection method. We can measure the actual flow rate, y
given some valve opening, u.
Where:
Set the minimum valve opening to 0% (u_min) and maximum opening to 100%
(u_max).
Set the desired flow rate to 10 L/min (y_desired).
Set a tolerance value for an acceptable error in the flow rate, say 0.1 L/min
(ε).Iterate until convergence:
Calculate the midpoint valve opening (u_mid) as the average value of u_min and
u_max.
Measure the actual flow rate (y_actual) for the midpoint valve opening (u_mid).
Check the difference between the desired and actual flow rates:
If |y_desired - y_actual| ≤ ε, then u_mid is a solution.\nIf y_desired < y_actual,
then the valve is overshooting the target. Update u_max to u_mid and repeat
from step 2
If y_desired > y_actual, then the valve is undershooting the target. Update u_min
to u_mid and repeat from step 2.
Python:
CODE:
def measure_flow_rate(valve_opening):
# Simulate measurement (replace with actual sensor data)
return valve_opening * 0.8 # This is a non-linear relationship between valve opening
and flow rate
# Example usage
y_desired = 10 # L/min
epsilon = 0.1 # L/min
valve_opening = find_valve_opening(y_desired, epsilon)
Problem 2.
A composite wall is made of a layer of brick, L1 thick with thermal conductivity k1,
and a layer of concrete, L2 thick with thermal conductivity k2. The surface on one side
of the brick, x = 0, is held at T1, while the surface on the other side of the concrete, x =
L1 + L2, is held at T2. We wish to determine the temperature, Ti, at the interface
between the brick and concrete.
Where:
Problem definition:
Specify the thicknesses (L1, L2) and thermal conductivities (k1, k2) for the two
materials.
Specify the constant temperatures (T1, T2) on the outer surfaces.
We can write an equation relating the interface temperature, Ti, to the heat flux,
q, through the wall using the thermal resistances of each layer. This equation will
be nonlinear due to the temperature dependence of the thermal conductivity
(optional in more complex problems).
Let f(Ti) be the difference of the heat flux computed from an assumed interface
temperature from the actual heat flux computed from the known temperature
difference T1 - T2.
The derivative of f(Ti), which is the rate of change of the error with the interface
temperature.
Apply Newton-Raphson: Guess the interface temperature, Ti_guess.
Iterate via the equation: Ti_(n+1) = Ti_n - f(Ti_n) / f'(Ti_n)\nRepeat the iterations,
stopping when the absolute change in the interface temperature between two
steps falls below some set tolerance value, epsilon.
Python:
CODE:
def thermal_resistance(thickness, conductivity):
return thickness / conductivity
# Example usage
T1 = 100 # degC
T2 = 20 # degC
L1 = 0.1 # m
L2 = 0.2 # m
k1 = 0.5 # W/m-K
k2 = 1.2 # W/m-K
Ti_guess = 50 # degC (initial guess)
epsilon = 0.1 # degC (tolerance)
FALSE-POSITION METHOD:
Problem 3.
Where:
Python: