3 from matplotlib
import pyplot
as plt
6 from analysisSharedFunctions
import loadYaml, loadFile
7 from plotSetUp
import setSvgLatexMatplotlibSettings, \
8 colors_qualitative_short
as colors_short, \
17 numeric_method="_midpoint_"
25 if(comparison_name ==
""):
31 print(
"Can only run test 1 if no fiction, neighbor springs, \ 32 damper is activated and the pad behaves as it's fastened to the roof surface. ")
33 print(
"Can only run test 2 if no friction, stationary springs \ 34 damper is activated and the pad behaves as it's fastened to the roof surface. ")
39 print(
"Only pullings springs in input.")
42 print(
"Only neighbor springs in input.")
70 self.
results_path = os.path.dirname(os.path.realpath(__file__)) +
"/../../../results/" 78 print(
"Remember, this code assumes that the only difference between the two runs is the stepsize.")
96 self.
x = np.linspace(start=start, stop=stop, num=len(self.
block_position[0]))
121 no_neighbor_springs = self.
run_parameters[
"Debug"][
"debug_no_neighbor_springs"]
125 [no_friction, no_neighbor_springs, no_pad])
129 no_stationary_springs = self.
run_parameters[
"Debug"][
"debug_no_stationary_springs"]
132 if(no_stationary_springs
and no_damper
and not no_pad):
136 [no_friction, no_stationary_springs, no_pad])
146 m_u = m_scale_mass*m_mass_x/N
147 k_p = m_scale_P*m_k_P0/N
149 energy_only_pulling_springs_test = 1/2 * m_u * \
150 np.sum(np.power(block_velocity, 2), axis=0) + \
151 1/2 * k_p * np.sum(np.power(block_position, 2), axis=0)
152 return(energy_only_pulling_springs_test)
161 m_u = m_scale_mass*m_mass_x/N
162 k_c = m_scale_C*m_k_P0*N
164 last_energy_ledd = block_position[1:,] - block_position[:-1,]
166 energy_only_neighbor_springs_test = 1/2 * m_u * np.sum(np.power(block_velocity, 2), axis=0) + \
167 1/2 * k_c * np.sum(np.power(last_energy_ledd, 2), axis=0)
169 return(energy_only_neighbor_springs_test)
175 return energy_array[-1] - energy_array[0]
180 energy_test_result_comparison
183 error_comparison = self.
calculateError(energy_test_result_comparison)
185 ratio = error/error_comparison
187 print(error, error_comparison, ratio)
190 plt.plot(self.
x, energy_test_result, label=
"Energy",
191 color=colors_short[0],
192 linestyle=linestyles[0])
195 plt.ylim(0, np.max(energy_test_result)*(1.10))
205 energy_test_result_comparison,
208 self.
compareError(energy_test_result, energy_test_result_comparison)
209 plt.plot(self.
x, energy_test_result,
211 color=colors_short[2],
212 linestyle=linestyles[2])
213 plt.plot(self.
x_comparison, energy_test_result_comparison,
215 color=colors_short[1],
216 linestyle=linestyles[1])
219 plt.ylim(0, np.max([np.max(energy_test_result), np.max(energy_test_result_comparison)])*(1.10))
223 plt.legend(title=
"\$dt\$")
228 if(len(sys.argv) > 2):
229 checkEnergy =
CheckEnergy(sys.argv[1], sys.argv[2])
230 elif(len(sys.argv) == 2):
236 if __name__ ==
"__main__":
def comparisonResult(self, comparison_name, numeric_method)
def plotEnergyTestComparison(self, energy_test_result, energy_test_result_comparison, zoom=True)
def calculateError(self, energy_array)
one_block_boolean_comparison
def checkPossibleEnergytests(self)
def testTerminalMessage(self)
def __init__(self, run_name="", comparison_name="", numeric_method="_midpoint_")
def plotEnergyTest(self, energy_test_result, zoom=True)
def loadComparisonFiles(self, comparison_name, numeric_method)
def onlyNeighborSpringsEnergyTest(self, block_velocity, block_position)
def loadFiles(self, run_name, numeric_method)
block_position_comparison
def compareError(self, energy_test_result, energy_test_result_comparison)
def checkOnlyPullingEnergyTest(self)
def onlyPullingSpringsEnergyTest(self, block_velocity, block_position)
def loadFile(run_name, shared_names, selected='pad_position.csv')
def checkOnlyNeighborEnergyTest(self)
def setUpPlotComparison(self)
block_velocity_comparison
def setSvgLatexMatplotlibSettings(pyplot)