%matplotlib ipympl
import pyvisco as visco
from pyvisco import styles
styles.format_fig()
#Load user master curve in frequency domain
data = visco.load.file('./time_master/time_user_master.csv')
RefT = -5
domain = 'time'
modul = 'E'
df_master, units = visco.load.user_master(data, domain, RefT, modul)
#Smooth
win = 1
df_master = visco.master.smooth(df_master, win)
fig_smooth = visco.master.plot_smooth(df_master, units)
#Discretize number of Prony terms
df_dis = visco.prony.discretize(df_master)
fig_dis = visco.prony.plot_dis(df_master, df_dis, units)
#Fit Prony series parameter
prony, df_GMaxw = visco.prony.fit(df_dis, df_master)
fig_fit = visco.prony.plot_fit(df_master, df_GMaxw, units)
#Plot Generalized Maxwell model
fig_GMaxw = visco.prony.plot_GMaxw(df_GMaxw, units);
#Compare Python fit with ANSYS APDL
df_prony_ANSYS = visco.verify.load_prony_ANSYS('./time_master/prony_terms.MPL')
prony_ANSYS = visco.verify.prep_prony_ANSYS(df_prony_ANSYS, prony, E_0 = 1739.03)
nprony = prony_ANSYS['df_terms'].shape[0]
df_GMaxw_ANSYS = visco.prony.calc_GMaxw(**prony_ANSYS, decades = nprony)
fig_fit_ANSYS = visco.verify.plot_fit_ANSYS(df_master, df_GMaxw, df_GMaxw_ANSYS, units)
fig_coeff = visco.prony.plot_param([prony, prony_ANSYS], ['Python', 'Ansys'])