@@ -132,19 +132,23 @@ plot!(p, grid = true)
132132
133133# Generate Timeline
134134datat = timeline (t_start = 0 , t_end = 20.0 , step = 0.02 ) # Create a timeline from 0 to 20 seconds with a step size of 0.02 seconds
135- # Generate Stress Data (Ramp & hold)
135+ # # Generate Stress Data (Ramp & hold)
136136dramp_stress = stressfunction (datat, ramp (offset = 4.0 , gradient = 0.8 )) # Generate a ramp stress function with offset 4.0 and gradient 0.8
137137dhold_stress = dramp_stress - stressfunction (datat, ramp (offset = 5.0 , gradient = 0.8 )) # Generate a hold stress function by subtracting a shifted ramp
138- # Define the rheological model and predict
138+
139+ # # Define the rheological model and predict
139140model = RheoModel (SLS_Zener, (η = 1 , kᵦ = 1 , kᵧ = 1 ))
140141data = modelpredict (dhold_stress, model)
141- # Fit three models to the data
142+
143+ # # Fit three models to the data
142144SLS_Zener_model = modelfit (data, SLS_Zener, stress_imposed)
143145Maxwell_model = modelfit (data, Maxwell, stress_imposed)
144146BurgersLiquid_model = modelfit (data, BurgersLiquid, stress_imposed)
145- # Call the extractfitdata function to extract fitting data
147+
148+ # # Call the extractfitdata function to extract fitting data
146149extracted_data = extractfitdata (data)
147- # Determine which model fits best by comparing errors
150+
151+ # # Determine which model fits best by comparing errors
148152function find_best_model (extracted_data)
149153 best_model = " "
150154 min_error = Inf
@@ -165,13 +169,15 @@ end
165169
166170best_model, min_error = find_best_model (extracted_data)
167171
168- # Create strain-only data for model predictions
172+ # # Create strain-only data for model predictions
169173stress_only_data = onlystress (data)
170- # Get model predictions for plotting
174+
175+ # # Get model predictions for plotting
171176SLS_Zener_predict = modelpredict (stress_only_data, SLS_Zener_model)
172177Maxwell_predict = modelpredict (stress_only_data, Maxwell_model)
173178BurgersLiquid_predict = modelpredict (stress_only_data, BurgersLiquid_model)
174- # Plot data and fitted models
179+
180+ # # Plot data and fitted models
175181p = scatter (data. t, data. ϵ,
176182 color = :green ,
177183 label = " Original Data" ,
@@ -183,6 +189,7 @@ p = scatter(data.t, data.ϵ,
183189 grid = true ,
184190 framestyle = :box
185191)
192+
186193# # Overlay fitted models
187194plot! (p, SLS_Zener_predict. t, SLS_Zener_predict. ϵ, color = :red , linestyle = :solid , linewidth = 3 , label = " SLS_Zener Model" )
188195plot! (p, Maxwell_predict. t, Maxwell_predict. ϵ, color = :blue , linestyle = :dash , linewidth = 3 , label = " Maxwell Model" )
0 commit comments