import numpy as np
import matplotlib.pyplot as plt
import pandas as pd def calculate_E(ix, iy, i_phi):
return np.sqrt((ix * iy) / (ix + iy - i_phi))
ix_value = float(input("Enter the value for ix: "))
iy_value = float(input("Enter the value for iy: "))
phi_values = np.arange(0, 361, 10)
E_values = []
i_phi_values = [] # Loop to accept i(φ) values and calculate E, phi will increase by 10° each time
for phi in phi_values:
i_phi = float(input(f"Enter the value for i({phi}°): "))
E = calculate_E(ix_value, iy_value, i_phi)
E_values.append(E)
i_phi_values.append(i_phi) # Convert the data into a pandas DataFrame for tabular display
data = {
'φ (Degrees)': phi_values,
'i(φ)': i_phi_values,
'E': E_values
}
df = pd.DataFrame(data) # Plot the E-φ relationship curve in polar coordinates to create an elliptical form
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
ax.plot(np.deg2rad(phi_values), E_values)
ax.set_theta_zero_location('N') # Set the direction of 0° to the top of the plot
ax.set_theta_direction(-1) # Set the theta direction to clockwise # Display the table and the plot
plt.show()
print(df)