I have made a function which returns a value for a force depending on the z position (z_pos). I would like to plot these results (shear diagram for the engineers here), however I get the following error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I have tried it both with arange and linspace, see the code here:
import matplotlib.pyplot as plt
import numpy as np
#values in kN and m
FyFL = 520
FyRL = 1246
L = 40.
Lf1 = 2.
Lf2 = 25.5
g = 9.81
W = 60000
q = (3*g*W/L)/1000 #kN/m
print q
def int_force_y(FyFL, FyRL, L, Lf1, Lf2, q, z_pos):
if z_pos <= Lf1:
int_fc_y = -q*z_pos
elif z_pos > Lf1 and z_pos < Lf1+Lf2:
int_fc_y = -q*Lf1 + FyFL-q*z_pos
elif z_pos >= Lf2 and z_pos <= 40.:
int_fc_y = -q*Lf1 + FyFL-q*(Lf1+Lf2)-q*z_pos
else:
return "No valid z_pos"
return int_fc_y
z_pos = np.arange(0,41,1)
y = int_force_y(FyFL, FyRL, L, Lf1, Lf2, q, z_pos)
plt.plot(z_pos,y)
plt.show()
Help is very much appreciated!