Inflation of a sphere by an internal pressure#
Units#
Length: mm
Mass: kg
Time: s
Force: milliNewtons
Stress: kPa
Software:#
Dolfinx v0.8.0
In the collection “Example Codes for Coupled Theories in Solid Mechanics,”
By Eric M. Stewart, Shawn A. Chester, and Lallit Anand.
Import modules#
# Import FEnicSx/dolfinx
import dolfinx
# For numerical arrays
import numpy as np
# For MPI-based parallelization
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
# PETSc solvers
from petsc4py import PETSc
# specific functions from dolfinx modules
from dolfinx import fem, mesh, io, plot, log
from dolfinx.fem import (Constant, dirichletbc, Function, functionspace, Expression )
from dolfinx.fem.petsc import NonlinearProblem
from dolfinx.nls.petsc import NewtonSolver
from dolfinx.io import VTXWriter, XDMFFile
# specific functions from ufl modules
import ufl
from ufl import (TestFunctions, TrialFunction, Identity, grad, det, div, dev, inv, tr, sqrt, conditional ,\
gt, dx, inner, derivative, dot, ln, split)
# basix finite elements (necessary for dolfinx v0.8.0)
import basix
from basix.ufl import element, mixed_element, quadrature_element
# Matplotlib for plotting
import matplotlib.pyplot as plt
plt.close('all')
# For timing the code
from datetime import datetime
# Set level of detail for log messages (integer)
# Guide:
# CRITICAL = 50, // errors that may lead to data corruption
# ERROR = 40, // things that HAVE gone wrong
# WARNING = 30, // things that MAY go wrong later
# INFO = 20, // information of general interest (includes solver info)
# PROGRESS = 16, // what's happening (broadly)
# TRACE = 13, // what's happening (in detail)
# DBG = 10 // sundry
#
log.set_log_level(log.LogLevel.WARNING)
Define geometry#
'''''''''''''''''''''
DEFINE GEOMETRY
'''''''''''''''''''''
# Thick-walled sphere dimensions
Ro = 11 # mm outer radius
Ri = 10 # mm inner radius
# Pull in the mesh *.xdmf file and read any named domains in the mesh.
with XDMFFile(MPI.COMM_WORLD,"meshes/spherical_shell.xdmf",'r') as infile:
domain = infile.read_mesh(name="Grid",xpath="/Xdmf/Domain")
cell_tags = infile.read_meshtags(domain,name="Grid")
# Create facet to cell connectivity required to determine boundary facets.
domain.topology.create_connectivity(domain.topology.dim, domain.topology.dim-1)
# Read in facet tags from an *.xdmf file.
with XDMFFile(MPI.COMM_WORLD, "meshes/facet_spherical_shell.xdmf", "r") as xdmf:
facet_tags = xdmf.read_meshtags(domain, name="Grid")
x = ufl.SpatialCoordinate(domain)
Print out the unique facet index numbers
top_imap = domain.topology.index_map(2) # index map of 2D entities in domain (facets)
values = np.zeros(top_imap.size_global) # an array of zeros of the same size as number of 2D entities
values[facet_tags.indices]=facet_tags.values # populating the array with facet tag index numbers
print(np.unique(facet_tags.values)) # printing the unique indices
# Surface numbering from gmsh:
# Physical Surface("yBot", 12)
# Physical Surface("zBot", 13)
# Physical Surface("xBot", 14)
# Physical Surface("inner_surf", 15)
[12 13 14 15]
Visualize reference configuration and boundary facets
import pyvista
pyvista.set_jupyter_backend('html')
from dolfinx.plot import vtk_mesh
pyvista.start_xvfb()
# initialize a plotter
plotter = pyvista.Plotter()
# Add the mesh -- I make the 3D mesh opaque, so that 2D surfaces stand out.
topology, cell_types, geometry = plot.vtk_mesh(domain, domain.topology.dim)
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)
plotter.add_mesh(grid, show_edges=True, opacity=0.5)
# Add colored 2D surfaces for the named surfaces
yBot = pyvista.UnstructuredGrid(*vtk_mesh(domain, domain.topology.dim-1,facet_tags.indices[facet_tags.values==12]) )
zBot = pyvista.UnstructuredGrid(*vtk_mesh(domain, domain.topology.dim-1,facet_tags.indices[facet_tags.values==13]) )
xBot = pyvista.UnstructuredGrid(*vtk_mesh(domain, domain.topology.dim-1,facet_tags.indices[facet_tags.values==14]) )
inner_surf = pyvista.UnstructuredGrid(*vtk_mesh(domain, domain.topology.dim-1,facet_tags.indices[facet_tags.values==15]) )
#
actor = plotter.add_mesh(yBot, show_edges=True,color="blue") # yBot face is blue
actor2 = plotter.add_mesh(zBot, show_edges=True,color="red") # zBot is red
actor3 = plotter.add_mesh(xBot, show_edges=True,color="green") # xBot is green
actor4 = plotter.add_mesh(inner_surf, show_edges=True,color="yellow") # inner surface is yellow
labels = dict(zlabel='Z', xlabel='X', ylabel='Y')
plotter.add_axes(**labels)
plotter.screenshot("mesh.png")
from IPython.display import Image
Image(filename='mesh.png')

Define boundary and volume integration measure#
# Define the boundary integration measure "ds" using the facet tags,
# also specify the number of surface quadrature points.
ds = ufl.Measure('ds', domain=domain, subdomain_data=facet_tags, metadata={'quadrature_degree':4})
# Define the volume integration measure "dx"
# also specify the number of volume quadrature points.
dx = ufl.Measure('dx', domain=domain, metadata={'quadrature_degree': 4})
# Define facet normal
n = ufl.FacetNormal(domain)
Material parameters#
-Arruda-Boyce model
Gshear_0 = Constant(domain,PETSc.ScalarType(280.0)) # Ground state shear modulus
lambdaL = Constant(domain,PETSc.ScalarType(5.12)) # Locking stretch
Kbulk = Constant(domain,PETSc.ScalarType(1000.0*Gshear_0))
Function spaces#
# Define function space, both vectorial and scalar
# dolfinx v0.8.0 syntax:
U2 = element("Lagrange", domain.basix_cell(), 2, shape=(3,)) # For displacement
P1 = element("Lagrange", domain.basix_cell(), 1) # For pressure
#
TH = mixed_element([U2, P1]) # Taylor-Hood style mixed element
ME = functionspace(domain, TH) # Total space for all DOFs
# Define actual functions with the required DOFs
w = Function(ME)
u, p = split(w) # displacement u, pressure p
# A copy of functions to store values in the previous step
w_old = Function(ME)
u_old, p_old = split(w_old)
# Define test functions
u_test, p_test = TestFunctions(ME)
# Define trial functions needed for automatic differentiation
dw = TrialFunction(ME)
Initial conditions#
The initial conditions for degrees of freedom u and p are zero everywhere
These are imposed automatically, since we have not specified any non-zero initial conditions.
Subroutines for kinematics and constitutive equations#
# Deformation gradient
def F_calc(u):
Id = Identity(3)
F = Id + grad(u)
return F
def lambdaBar_calc(u):
F = F_calc(u)
C = F.T*F
Cdis = J**(-2/3)*C
I1 = tr(Cdis)
lambdaBar = sqrt(I1/3.0)
return lambdaBar
def zeta_calc(u):
lambdaBar = lambdaBar_calc(u)
# Use Pade approximation of Langevin inverse
z = lambdaBar/lambdaL
z = conditional(gt(z,0.95), 0.95, z) # Keep simulation from blowing up
beta = z*(3.0 - z**2.0)/(1.0 - z**2.0)
zeta = (lambdaL/(3*lambdaBar))*beta
return zeta
# Generalized shear modulus for Arruda-Boyce model
def Gshear_AB_calc(u):
zeta = zeta_calc(u)
Gshear = Gshear_0 * zeta
return Gshear
#---------------------------------------------
# Subroutine for calculating the Cauchy stress
#---------------------------------------------
def T_calc(u,p):
Id = Identity(3)
F = F_calc(u)
J = det(F)
B = F*F.T
Bdis = J**(-2/3)*B
Gshear = Gshear_AB_calc(u)
T = (1/J)* Gshear * dev(Bdis) - p * Id
return T
#----------------------------------------------
# Subroutine for calculating the Piola stress
#----------------------------------------------
def Piola_calc(u, p):
Id = Identity(3)
F = F_calc(u)
J = det(F)
#
T = T_calc(u,p)
#
Tmat = J * T * inv(F.T)
return Tmat
Evaluate kinematics and constitutive relations#
F = F_calc(u)
J = det(F)
lambdaBar = lambdaBar_calc(u)
# Piola stress
Tmat = Piola_calc(u, p)
Weak forms#
# Residuals:
# Res_0: Balance of forces (test fxn: u)
# Res_1: Coupling pressure (test fxn: p)
# Surface numbering from gmsh:
# Physical Surface("yBot", 12)
# Physical Surface("zBot", 13)
# Physical Surface("xBot", 14)
# Physical Surface("inner_surf", 15)
# Cofactor of F
Fcof = J*inv(F.T)
# Create a constant for the pressure value
pressRampCons = Constant(domain,PETSc.ScalarType(pressRamp(0)))
# Configuration-dependent traction
traction = - pressRampCons*dot(Fcof,n)
# The weak form for the balance of forces
Res_0 = inner(Tmat, grad(u_test) )*dx - dot(traction, u_test)*ds(15)
# The weak form for the pressure
fac_p = ln(J)/J
#
Res_1 = dot( (p/Kbulk + fac_p), p_test)*dx
# Total weak form
Res = Res_0 + Res_1
# Automatic differentiation tangent:
a = derivative(Res, w, dw)
Set-up output files#
# results file name
results_name = "3D_sphere_inflate"
# Function space for projection of results
# v0.8.0 syntax:
U1 = element("DG", domain.basix_cell(), 1, shape=(3,)) # For displacement
P0 = element("DG", domain.basix_cell(), 1) # For pressure
V2 = fem.functionspace(domain, U1) #Vector function space
V1 = fem.functionspace(domain, P0) #Scalar function space, must be discontinuous here since materials are discontinuous.
# fields to write to output file
u_vis = Function(V2)
u_vis.name = "disp"
p_vis = Function(V1)
p_vis.name = "p"
J_vis = Function(V1)
J_vis.name = "J"
J_expr = Expression(J,V1.element.interpolation_points())
lambdaBar_vis = Function(V1)
lambdaBar_vis.name = "lambdaBar"
lambdaBar_expr = Expression(lambdaBar,V1.element.interpolation_points())
P11 = Function(V1)
P11.name = "P11"
P11_expr = Expression(Tmat[0,0],V1.element.interpolation_points())
P22 = Function(V1)
P22.name = "P22"
P22_expr = Expression(Tmat[1,1],V1.element.interpolation_points())
P33 = Function(V1)
P33.name = "P33"
P33_expr = Expression(Tmat[2,2],V1.element.interpolation_points())
T = Tmat*F.T/J
T0 = T - (1/3)*tr(T)*Identity(3)
Mises = sqrt((3/2)*inner(T0, T0))
Mises_vis= Function(V1,name="Mises")
Mises_expr = Expression(Mises,V1.element.interpolation_points())
# set up the output VTX files.
file_results = VTXWriter(
MPI.COMM_WORLD,
"results/" + results_name + ".bp",
[ # put the functions here you wish to write to output
u_vis, p_vis, J_vis, P11, P22, P33, lambdaBar_vis,
Mises_vis,
],
engine="BP4",
)
def writeResults(t):
# Output field interpolation
u_vis.interpolate(w.sub(0))
p_vis.interpolate(w.sub(1))
J_vis.interpolate(J_expr)
P11.interpolate(P11_expr)
P22.interpolate(P22_expr)
P33.interpolate(P33_expr)
lambdaBar_vis.interpolate(lambdaBar_expr)
Mises_vis.interpolate(Mises_expr)
# Write output fields
file_results.write(t)
Infrastructure for pulling out time history data (force, displacement, etc.)#
# infrastructure for evaluating functions at a certain point efficiently
pointForDisp = np.array([Ri, 0, 0])
bb_tree = dolfinx.geometry.bb_tree(domain,domain.topology.dim)
cell_candidates = dolfinx.geometry.compute_collisions_points(bb_tree, pointForDisp)
colliding_cells = dolfinx.geometry.compute_colliding_cells(domain, cell_candidates, pointForDisp).array
Name the analysis step#
# Give the step a descriptive name
step = "Stretch"
Boundary condtions#
# Surface labels from gmsh:
# Physical Surface("yBot", 12)
# Physical Surface("zBot", 13)
# Physical Surface("xBot", 14)
# Physical Surface("inner_surf", 15)
# Find the specific DOFs which will be constrained.
xBtm_u1_dofs = fem.locate_dofs_topological(ME.sub(0).sub(0), facet_tags.dim, facet_tags.find(14))
yBtm_u2_dofs = fem.locate_dofs_topological(ME.sub(0).sub(1), facet_tags.dim, facet_tags.find(12))
zBtm_u3_dofs = fem.locate_dofs_topological(ME.sub(0).sub(2), facet_tags.dim, facet_tags.find(13))
# building Dirichlet BCs
bcs_1 = dirichletbc(0.0, xBtm_u1_dofs, ME.sub(0).sub(0)) # u1 fix - xBtm
bcs_2 = dirichletbc(0.0, yBtm_u2_dofs, ME.sub(0).sub(1)) # u2 fix - yBtm
bcs_3 = dirichletbc(0.0, zBtm_u3_dofs, ME.sub(0).sub(2)) # u3 fix - zBtm
bcs = [bcs_1, bcs_2, bcs_3]
Define the nonlinear variational problem#
# Set up nonlinear problem
problem = NonlinearProblem(Res, w, bcs, a)
# the global newton solver and params
solver = NewtonSolver(MPI.COMM_WORLD, problem)
solver.convergence_criterion = "incremental"
solver.rtol = 1e-8
solver.atol = 1e-8
solver.max_it = 50
solver.report = True
# The Krylov solver parameters.
ksp = solver.krylov_solver
opts = PETSc.Options()
option_prefix = ksp.getOptionsPrefix()
opts[f"{option_prefix}ksp_type"] = "preonly" # "preonly" works equally well
opts[f"{option_prefix}pc_type"] = "lu" # do not use 'gamg' pre-conditioner
opts[f"{option_prefix}pc_factor_mat_solver_type"] = "mumps"
opts[f"{option_prefix}ksp_max_it"] = 30
ksp.setFromOptions()
Start calculation loop#
# Variables for storing time history
totSteps = numSteps+1
timeHist0 = np.zeros(shape=[totSteps])
timeHist1 = np.zeros(shape=[totSteps])
timeHist2 = np.zeros(shape=[totSteps])
#Iinitialize a counter for reporting data
ii=0
# Write initial state to file
writeResults(t=0.0)
# Print out message for simulation start
print("------------------------------------")
print("Simulation Start")
print("------------------------------------")
# Store start time
startTime = datetime.now()
# Time-stepping solution procedure loop
while (round(t + dt, 9) <= Ttot):
# increment time
t += dt
# increment counter
ii += 1
# update time variables in time-dependent BCs
pressRampCons.value = pressRamp(t)
# Solve the problem
try:
(iter, converged) = solver.solve(w)
except: # Break the loop if solver fails
print("Ended Early")
break
# Collect results from MPI ghost processes
w.x.scatter_forward()
# Write output to file
writeResults(t)
# Update DOFs for next step
w_old.x.array[:] = w.x.array
# Store time history variables at this time
timeHist0[ii] = t # current time
#
timeHist1[ii] = pressRamp(t) # time history of applied pressure
#
timeHist2[ii] = w.sub(0).sub(0).eval([Ri, 0.0, 0.0],colliding_cells[0])[0] # time history of displacement
# Print progress of calculation
if ii%1 == 0:
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print("Step: {} | Increment: {}, Iterations: {}".\
format(step, ii, iter))
print(" Simulation Time: {} s of {} s".\
format(round(t,4), Ttot))
print()
# close the output file.
file_results.close()
# End analysis
print("-----------------------------------------")
print("End computation")
# Report elapsed real time for the analysis
endTime = datetime.now()
elapseTime = endTime - startTime
print("------------------------------------------")
print("Elapsed real time: {}".format(elapseTime))
print("------------------------------------------")
------------------------------------
Simulation Start
------------------------------------
Step: Stretch | Increment: 1, Iterations: 3
Simulation Time: 0.1 s of 10.0 s
Step: Stretch | Increment: 2, Iterations: 3
Simulation Time: 0.2 s of 10.0 s
Step: Stretch | Increment: 3, Iterations: 3
Simulation Time: 0.3 s of 10.0 s
Step: Stretch | Increment: 4, Iterations: 3
Simulation Time: 0.4 s of 10.0 s
Step: Stretch | Increment: 5, Iterations: 3
Simulation Time: 0.5 s of 10.0 s
Step: Stretch | Increment: 6, Iterations: 3
Simulation Time: 0.6 s of 10.0 s
Step: Stretch | Increment: 7, Iterations: 3
Simulation Time: 0.7 s of 10.0 s
Step: Stretch | Increment: 8, Iterations: 3
Simulation Time: 0.8 s of 10.0 s
Step: Stretch | Increment: 9, Iterations: 3
Simulation Time: 0.9 s of 10.0 s
Step: Stretch | Increment: 10, Iterations: 3
Simulation Time: 1.0 s of 10.0 s
Step: Stretch | Increment: 11, Iterations: 3
Simulation Time: 1.1 s of 10.0 s
Step: Stretch | Increment: 12, Iterations: 3
Simulation Time: 1.2 s of 10.0 s
Step: Stretch | Increment: 13, Iterations: 3
Simulation Time: 1.3 s of 10.0 s
Step: Stretch | Increment: 14, Iterations: 3
Simulation Time: 1.4 s of 10.0 s
Step: Stretch | Increment: 15, Iterations: 3
Simulation Time: 1.5 s of 10.0 s
Step: Stretch | Increment: 16, Iterations: 3
Simulation Time: 1.6 s of 10.0 s
Step: Stretch | Increment: 17, Iterations: 3
Simulation Time: 1.7 s of 10.0 s
Step: Stretch | Increment: 18, Iterations: 3
Simulation Time: 1.8 s of 10.0 s
Step: Stretch | Increment: 19, Iterations: 3
Simulation Time: 1.9 s of 10.0 s
Step: Stretch | Increment: 20, Iterations: 3
Simulation Time: 2.0 s of 10.0 s
Step: Stretch | Increment: 21, Iterations: 3
Simulation Time: 2.1 s of 10.0 s
Step: Stretch | Increment: 22, Iterations: 3
Simulation Time: 2.2 s of 10.0 s
Step: Stretch | Increment: 23, Iterations: 3
Simulation Time: 2.3 s of 10.0 s
Step: Stretch | Increment: 24, Iterations: 3
Simulation Time: 2.4 s of 10.0 s
Step: Stretch | Increment: 25, Iterations: 3
Simulation Time: 2.5 s of 10.0 s
Step: Stretch | Increment: 26, Iterations: 3
Simulation Time: 2.6 s of 10.0 s
Step: Stretch | Increment: 27, Iterations: 3
Simulation Time: 2.7 s of 10.0 s
Step: Stretch | Increment: 28, Iterations: 3
Simulation Time: 2.8 s of 10.0 s
Step: Stretch | Increment: 29, Iterations: 3
Simulation Time: 2.9 s of 10.0 s
Step: Stretch | Increment: 30, Iterations: 3
Simulation Time: 3.0 s of 10.0 s
Step: Stretch | Increment: 31, Iterations: 3
Simulation Time: 3.1 s of 10.0 s
Step: Stretch | Increment: 32, Iterations: 4
Simulation Time: 3.2 s of 10.0 s
Step: Stretch | Increment: 33, Iterations: 4
Simulation Time: 3.3 s of 10.0 s
Step: Stretch | Increment: 34, Iterations: 4
Simulation Time: 3.4 s of 10.0 s
Step: Stretch | Increment: 35, Iterations: 4
Simulation Time: 3.5 s of 10.0 s
Step: Stretch | Increment: 36, Iterations: 4
Simulation Time: 3.6 s of 10.0 s
Step: Stretch | Increment: 37, Iterations: 4
Simulation Time: 3.7 s of 10.0 s
Step: Stretch | Increment: 38, Iterations: 4
Simulation Time: 3.8 s of 10.0 s
Step: Stretch | Increment: 39, Iterations: 4
Simulation Time: 3.9 s of 10.0 s
Step: Stretch | Increment: 40, Iterations: 4
Simulation Time: 4.0 s of 10.0 s
Step: Stretch | Increment: 41, Iterations: 4
Simulation Time: 4.1 s of 10.0 s
Step: Stretch | Increment: 42, Iterations: 4
Simulation Time: 4.2 s of 10.0 s
Step: Stretch | Increment: 43, Iterations: 4
Simulation Time: 4.3 s of 10.0 s
Step: Stretch | Increment: 44, Iterations: 4
Simulation Time: 4.4 s of 10.0 s
Step: Stretch | Increment: 45, Iterations: 4
Simulation Time: 4.5 s of 10.0 s
Step: Stretch | Increment: 46, Iterations: 4
Simulation Time: 4.6 s of 10.0 s
Step: Stretch | Increment: 47, Iterations: 4
Simulation Time: 4.7 s of 10.0 s
Step: Stretch | Increment: 48, Iterations: 4
Simulation Time: 4.8 s of 10.0 s
Step: Stretch | Increment: 49, Iterations: 4
Simulation Time: 4.9 s of 10.0 s
Step: Stretch | Increment: 50, Iterations: 4
Simulation Time: 5.0 s of 10.0 s
Step: Stretch | Increment: 51, Iterations: 4
Simulation Time: 5.1 s of 10.0 s
Step: Stretch | Increment: 52, Iterations: 4
Simulation Time: 5.2 s of 10.0 s
Step: Stretch | Increment: 53, Iterations: 4
Simulation Time: 5.3 s of 10.0 s
Step: Stretch | Increment: 54, Iterations: 4
Simulation Time: 5.4 s of 10.0 s
Step: Stretch | Increment: 55, Iterations: 4
Simulation Time: 5.5 s of 10.0 s
Step: Stretch | Increment: 56, Iterations: 4
Simulation Time: 5.6 s of 10.0 s
Step: Stretch | Increment: 57, Iterations: 4
Simulation Time: 5.7 s of 10.0 s
Step: Stretch | Increment: 58, Iterations: 4
Simulation Time: 5.8 s of 10.0 s
Step: Stretch | Increment: 59, Iterations: 4
Simulation Time: 5.9 s of 10.0 s
Step: Stretch | Increment: 60, Iterations: 4
Simulation Time: 6.0 s of 10.0 s
Step: Stretch | Increment: 61, Iterations: 4
Simulation Time: 6.1 s of 10.0 s
Step: Stretch | Increment: 62, Iterations: 4
Simulation Time: 6.2 s of 10.0 s
Step: Stretch | Increment: 63, Iterations: 4
Simulation Time: 6.3 s of 10.0 s
Step: Stretch | Increment: 64, Iterations: 4
Simulation Time: 6.4 s of 10.0 s
Step: Stretch | Increment: 65, Iterations: 4
Simulation Time: 6.5 s of 10.0 s
Step: Stretch | Increment: 66, Iterations: 4
Simulation Time: 6.6 s of 10.0 s
Step: Stretch | Increment: 67, Iterations: 4
Simulation Time: 6.7 s of 10.0 s
Step: Stretch | Increment: 68, Iterations: 4
Simulation Time: 6.8 s of 10.0 s
Step: Stretch | Increment: 69, Iterations: 4
Simulation Time: 6.9 s of 10.0 s
Step: Stretch | Increment: 70, Iterations: 4
Simulation Time: 7.0 s of 10.0 s
Step: Stretch | Increment: 71, Iterations: 4
Simulation Time: 7.1 s of 10.0 s
Step: Stretch | Increment: 72, Iterations: 4
Simulation Time: 7.2 s of 10.0 s
Step: Stretch | Increment: 73, Iterations: 4
Simulation Time: 7.3 s of 10.0 s
Step: Stretch | Increment: 74, Iterations: 4
Simulation Time: 7.4 s of 10.0 s
Step: Stretch | Increment: 75, Iterations: 4
Simulation Time: 7.5 s of 10.0 s
Step: Stretch | Increment: 76, Iterations: 4
Simulation Time: 7.6 s of 10.0 s
Step: Stretch | Increment: 77, Iterations: 4
Simulation Time: 7.7 s of 10.0 s
Step: Stretch | Increment: 78, Iterations: 4
Simulation Time: 7.8 s of 10.0 s
Step: Stretch | Increment: 79, Iterations: 4
Simulation Time: 7.9 s of 10.0 s
Step: Stretch | Increment: 80, Iterations: 4
Simulation Time: 8.0 s of 10.0 s
Step: Stretch | Increment: 81, Iterations: 4
Simulation Time: 8.1 s of 10.0 s
Step: Stretch | Increment: 82, Iterations: 4
Simulation Time: 8.2 s of 10.0 s
Step: Stretch | Increment: 83, Iterations: 4
Simulation Time: 8.3 s of 10.0 s
Step: Stretch | Increment: 84, Iterations: 4
Simulation Time: 8.4 s of 10.0 s
Step: Stretch | Increment: 85, Iterations: 4
Simulation Time: 8.5 s of 10.0 s
Step: Stretch | Increment: 86, Iterations: 4
Simulation Time: 8.6 s of 10.0 s
Step: Stretch | Increment: 87, Iterations: 4
Simulation Time: 8.7 s of 10.0 s
Step: Stretch | Increment: 88, Iterations: 4
Simulation Time: 8.8 s of 10.0 s
Step: Stretch | Increment: 89, Iterations: 4
Simulation Time: 8.9 s of 10.0 s
Step: Stretch | Increment: 90, Iterations: 4
Simulation Time: 9.0 s of 10.0 s
Step: Stretch | Increment: 91, Iterations: 4
Simulation Time: 9.1 s of 10.0 s
Step: Stretch | Increment: 92, Iterations: 4
Simulation Time: 9.2 s of 10.0 s
Step: Stretch | Increment: 93, Iterations: 4
Simulation Time: 9.3 s of 10.0 s
Step: Stretch | Increment: 94, Iterations: 4
Simulation Time: 9.4 s of 10.0 s
Step: Stretch | Increment: 95, Iterations: 5
Simulation Time: 9.5 s of 10.0 s
Step: Stretch | Increment: 96, Iterations: 5
Simulation Time: 9.6 s of 10.0 s
Step: Stretch | Increment: 97, Iterations: 5
Simulation Time: 9.7 s of 10.0 s
Ended Early
-----------------------------------------
End computation
------------------------------------------
Elapsed real time: 0:01:49.873143
------------------------------------------
Plot results#
# set plot font to size 14
font = {'size' : 14}
plt.rc('font', **font)
# Get array of default plot colors
prop_cycle = plt.rcParams['axes.prop_cycle']
colors = prop_cycle.by_key()['color']
# Only plot as far as we have time history data
ind = np.argmax(timeHist0)
# Pressure versus displacement curve:
#
fig = plt.figure()
#fig.set_size_inches(7,4)
ax=fig.gca()
plt.plot(timeHist1[:ind], timeHist2[:ind], c='b', linewidth=2.0, marker='.')
#-------------------------------------------------------------
#ax.set.xlim(-0.01,0.01)
#ax.set.ylim(-0.03,0.03)
#plt.axis('tight')
plt.grid(linestyle="--", linewidth=0.5, color='b')
ax.set_xlabel(r'Internal pressure, kPa')
ax.set_ylabel(r'Displacement of inner wall, mm')
ax.set_title("Internal pressure versus radial expansion curve", size=14, weight='normal')
from matplotlib.ticker import AutoMinorLocator,FormatStrFormatter
ax.xaxis.set_minor_locator(AutoMinorLocator())
ax.yaxis.set_minor_locator(AutoMinorLocator())
plt.show()
fig = plt.gcf()
fig.set_size_inches(7,5)
plt.tight_layout()
plt.savefig("results/pressurise_sphere.png", dpi=600)

<Figure size 700x500 with 0 Axes>