Load experiment
Tutorial on how to implement the preload-afterload experiment. This tutorial discusses how to build the model, how to switch between different patch types, and how to extract and plot information from the model.
As all projects, we start with importing packages.
from circadapt import CircAdapt
import numpy as np
import matplotlib.pyplot as plt
We then create an empty model. Then, we add the LoadExperiment wall object. This object is empty by default, but it needs at least 1 patch object to work. In this tutorial, we use the Patch object.
# %% Create custom model
model = CircAdapt('forward_euler')
model.add_component('LoadExperiment', 'PAE')
model.add_component('Patch', 'P', 'PAE')
model['LoadExperiment']['n_patch'] = 2
The model has to be parametized, as default parameter values do not make sense for this setup.
# %% Set model parameters
model.set('Model.t_cycle', 1e-0)
model.set('Solver.dt', 1e-3)
model.set('Solver.dt_export', 1e-3)
model['LoadExperiment']['Am_ref_afterload'] = 0.006
model['LoadExperiment']['T_afterload'] = 200
model['LoadExperiment']['n_iter'] = 5
model['Patch']['Am_ref'] = 0.005
model['Patch']['V_wall'] = 92.43*1e-6
model['Patch']['ADO'] = 3.0
model['Patch']['tr'] = 0.5
model['Patch']['td'] = 0.5
model['Patch']['k1'] = 10.
model['Patch']['v_max'] = 7.0
model['Patch']['dt'] = 0.2
model['Patch']['dt'] = [0.1, 0.1]
model.set('Model.PAE.pAE0.l_si', -0.04 + 2 * np.sqrt(
model['LoadExperiment']['Am_ref_afterload'][0]/model['Patch']['Am_ref'][0]))
model.set('Model.PAE.pAE1.l_si', model.get('Model.PAE.pAE0.l_si', dtype=float))
True
Now the model setup is finished and we can run the simulation. For this setup, only 1 run is sufficient.
# %% Run model
model.run(1)
The simulation will result in the stresses and tensions shown in the plot below.
# %% Plot model
fig = plt.figure(1, clear=True, figsize=(12, 8))
m = 2
n = 3
t = model.get('Solver.t') * 1e3
ax1 = fig.add_subplot(m, n, 1)
ax1.plot(t, model['Patch']['l_s'][:, 0])
ax1.plot(t, model['Patch']['l_si'][:, 0])
ax1.legend(['l_s', 'l_si'])
ax1.set_ylabel('Sarcomere length [$\\mu m$]')
ax4 = fig.add_subplot(m, n, 4)
ax4.plot(t, model['Patch']['Am'][:, 0]*1e4, label='Patch Am')
ax4.plot(t, model['Patch']['Am0'][:, 0]*1e4, label='Patch Am0')
ax4.set_ylabel('Segment area [$cm^2$]')
ax4.legend()
ax3 = fig.add_subplot(m, n, 3)
ax3.plot(t, model['Patch']['Sf'][:, 0]*1e-3, label='Sf')
ax3.plot(t, model['Patch']['Sf_ecm'][:, 0]*1e-3, label='SfEcm')
ax3.set_ylabel('Stress [kPa]')
ax3.legend()
ax2 = fig.add_subplot(m, n, 2)
ax2.plot(t, model['Patch']['C'][:, 0], label='C')
ax2.set_ylabel('C-curve [-]')
ax5 = fig.add_subplot(m, n, 5)
ax5.plot(t, model.get('Model.PAE.dA_dT')*1e4, label='Tension Wall')
ax5.set_ylabel('dA_dT [$cm^2/N$]')
ax6 = fig.add_subplot(m, n, 6)
ax6.plot(t, model.get('Model.PAE.T'), label='Tension Wall')
ax6.set_ylabel('Tension [N]')
# Plot design
for ax in [ax1, ax2, ax3, ax4, ax5, ax6]:
ax.spines[['right', 'top']].set_visible(False)
ax5.set_xlabel('Time [ms]')
plt.tight_layout()
plt.show()