The original tcl code can be found at https://opensees.berkeley.edu/wiki/inde ... solidation
The problem I have is that
op.element('9_4_QuadUP', eleTag, nI, nJ, nK, nL, nM, nN, nP, nQ, nR, thick, matTag, bulk, H2ODensity, hPerm, vPerm, wgtX, wgtY)
this line always leads to the restart of python kernel for some reason I do not understand.
The code runs until the line with element command.
Python version: 3.9.12
Any help is greatly appreciated.
Regards,
Steve
Python Code:
Code: Select all
[
from datetime import datetime
import openseespy.opensees as op
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Times New Roman"
import sys
#%%
# specify desired drainage type; 1 --> single drainage, 2 --> double drainage
drainage = 1
if drainage == 1:
print('Single Drainage')
elif drainage == 2:
print('Double Drainage')
else:
print('Wrong drainage condition!')
sys.exit(0)
#%%
#create model
#Remove the existing model, important!!!
op.wipe()
#%%
#=========================================
#1. Define Mesh Geometry
#=========================================
# number of elements in horizontal direction
numEleX = 1
# size of elements in horizontal direction (m)
sizeEleX = 1.0
# number of nodes in horizontal direction
numNodeX = numEleX* 2 + 1
# number of elements in vertical direction
numEleY = 11 # numEleY should be an odd number
# size of elements in vertical direction (m)
sizeEleY = 1.0
# number of nodes in vertical direction
numNodeY = 2 * numEleY+1
# total number of nodes
totalNumNode = 3*numNodeY
# total number of elements
totalNumEle = numEleY*numEleX
node_list = []
#-------------------------------------------------------------------------------------------
# 2. DEFINE CORNER NODES
#-------------------------------------------------------------------------------------------
op.model('basic', '-ndm', 2, '-ndf', 3) #corner nodes record PP
fig = plt.figure(figsize=(5,10))
ax0 = fig.add_subplot(211)
ax0.set_xlabel("x, m", fontsize=16)
ax0.set_ylabel("y, m", fontsize=16)
ax0.set_aspect('equal')
ax0.set_xlim(-1.0, 2.0)
ax0.set_ylim(-1.0,numEleY+1)
for i in range(numEleY):
if (i % 2) == 0:
nodeNum0 = 6*i
nodeNum1 = 6*i+2
nodeNum2 = 6*i+6
nodeNum3 = 6*i+8
node_list.append(nodeNum0)
node_list.append(nodeNum1)
node_list.append(nodeNum2)
node_list.append(nodeNum3)
Xcoord0 = 0.0
Xcoord1 = 1.0
Xcoord2 = 0.0
Xcoord3 = 1.0
Ycoord0 = i*1.0
Ycoord1 = i*1.0
Ycoord2 = i*1.0 + 1.0
Ycoord3 = i*1.0 + 1.0
#set corner nodes
op.node(nodeNum0, Xcoord0, Ycoord0)
op.node(nodeNum1, Xcoord1, Ycoord1)
op.node(nodeNum2, Xcoord2, Ycoord2)
op.node(nodeNum3, Xcoord3, Ycoord3)
#plot corner nodes
ax0.plot(Xcoord0, Ycoord0, 'ro', label = str(nodeNum0))
ax0.plot(Xcoord1, Ycoord1, 'ro', label = str(nodeNum1))
ax0.plot(Xcoord2, Ycoord2, 'ro', label = str(nodeNum2))
ax0.plot(Xcoord3, Ycoord3, 'ro', label = str(nodeNum3))
print('Finished creating corner soil nodes...')
nodeNum_surface1 = nodeNum3 #corner node on the surface
nodeNum_surface2 = nodeNum2
print('Number of nodes are:',nodeNum3+1)
#-------------------------------------------------------------------------------------------
# 3. DEFINE BOUNDARY CONDITIONS FOR CORNER NODES
#-------------------------------------------------------------------------------------------
# boundary conditions for base nodes depending upon selected drainage type
if drainage == 1: #single drainage, base fixed
op.fix(0, 1, 1, 0)
op.fix(2, 1, 1, 0)
elif drainage == 2: #double drainages, base deformation fixed, drainage free
op.fix(0, 1, 1, 1)
op.fix(2, 1, 1, 1)
#change the surface node to free-drainage no displacement in both directions
op.fix(nodeNum_surface1, 1 , 1, 0)
op.fix(nodeNum_surface2, 1 , 1, 0)
#print('Nodes with fixed X and Y displacement are:')
for i in range(numEleY): #first fix all other element in the x direction
if (i % 2) == 0:
nodeNum0 = 6*i
nodeNum1 = 6*i+2
nodeNum2 = 6*i+6
nodeNum3 = 6*i+8
if i != 0:
op.fix(nodeNum0, 1, 0, 0)
op.fix(nodeNum1, 1, 0, 0)
#print(nodeNum0)
#print(nodeNum1)
if i != numEleY-1:
op.fix(nodeNum2, 1, 0, 0)
op.fix(nodeNum3, 1, 0, 0)
#print(nodeNum2)
#print(nodeNum3)
print('Finished creating boundary conditions for corner nodes...')
#-------------------------------------------------------------------------------------------
# 4. DEFINE INTERIOR NODES
#-------------------------------------------------------------------------------------------
op.model('basic', '-ndm', 2, '-ndf', 2) #interior nodes do not record PP, 2 dof
for i in range(numEleY):
nodeNum0 = 6*i+1
nodeNum1 = 6*i+3
nodeNum2 = 6*i+4
nodeNum3 = 6*i+5
Xcoord0 = 0.5
Xcoord1 = 0.0
Xcoord2 = 0.5
Xcoord3 = 1.0
Ycoord0 = i*1.0
Ycoord1 = i+0.5
Ycoord2 = i+0.5
Ycoord3 = i+0.5
node_list.append(nodeNum0)
node_list.append(nodeNum1)
node_list.append(nodeNum2)
node_list.append(nodeNum3)
#set interior nodes
op.node(nodeNum0, Xcoord0, Ycoord0)
op.node(nodeNum1, Xcoord1, Ycoord1)
op.node(nodeNum2, Xcoord2, Ycoord2)
op.node(nodeNum3, Xcoord3, Ycoord3)
ax0.plot(Xcoord0, Ycoord0, 'bo', label = str(nodeNum0))
ax0.plot(Xcoord1, Ycoord1, 'bo', label = str(nodeNum1))
ax0.plot(Xcoord2, Ycoord2, 'bo', label = str(nodeNum2))
ax0.plot(Xcoord3, Ycoord3, 'bo', label = str(nodeNum3))
nodeNum_surface3 = 6*i+7
Xcoord = 0.5
Ycoord = i+1.0
op.node(nodeNum_surface3, Xcoord, Ycoord)
ax0.plot(Xcoord, Ycoord, 'bo', label = str(nodeNum0))
print('Finished creating all soil nodes...')
#-------------------------------------------------------------------------------------------
# 5. DEFINE BOUNDARY CONDITIONS FOR INTERIOR NODES
#-------------------------------------------------------------------------------------------
op.fix(1, 1, 1)
for i in range(numEleY):
nodeNum0 = 6*i+1
nodeNum1 = 6*i+3
nodeNum2 = 6*i+4
nodeNum3 = 6*i+5
if i==0:
op.fix(nodeNum1, 1, 0)
op.fix(nodeNum2, 1, 0)
op.fix(nodeNum3, 1, 0)
#print(nodeNum1,nodeNum2,nodeNum3)
else:
op.fix(nodeNum0, 1, 0)
op.fix(nodeNum1, 1, 0)
op.fix(nodeNum2, 1, 0)
op.fix(nodeNum3, 1, 0)
#print(nodeNum0,nodeNum1,nodeNum2,nodeNum3)
op.fix(nodeNum_surface3, 1, 0)
#make surface node equal displacement at degrees 1 & 2
op.equalDOF(nodeNum_surface1,nodeNum_surface2,1,2)
op.equalDOF(nodeNum_surface1,nodeNum_surface3,1,2)
print('Finished creating all boundary conditions and equalDOF...')
#-------------------------------------------------------------------------------------------
# 6. DEFINE MATERIAL PROPERTIES OF SOIL
#-------------------------------------------------------------------------------------------
# Constutive Model: PressureIndependMultiYield material
# saturated mass density (Mg/m3)
satDensity = 2.3
# fluid mass density (Mg/m3)
H2ODensity = 1.0
# shear modulus (kPa)
shear = 2.5e4
# bulk modulus (kPa)
bulk = 6.2e5
# undrained bulk modulus (kPa)
uBulk = 2.2e5
# vertical permeability, input value in m/s, units are modified to suit constitutive model
mPermV = 5.0e-5
vPerm = mPermV/9.81/H2ODensity
# horizontal permeability, input value in m/s, units are modified to suit constitutive model
mPermH = 5.0e-5
hPerm = mPermH/9.81/H2ODensity
# cohesion (kPa)
cohesion = 45.0
# friction angle (degrees)
phi = 0.0
# peak shear strain
gammaPeak = 0.1
# reference pressure (kPa)
refP = 80.0
# pressure dependency coefficient
pressCoeff = 0.0
# number of yield surfaces
numSurf = 22
#-------------------------------------------------------------------------------------------
# 7. DEFINE SOIL MATERIALS
#-------------------------------------------------------------------------------------------
'''
Soil Model: PressureIndependMultiYield
nDMaterial('PressureIndependMultiYield', matTag, nd, rho, refShearModul, refBulkModul,
cohesi, peakShearStra, frictionAng=0., refPress=100., pressDependCoe=0.,
noYieldSurf=20, *yieldSurf)
'''
matTag = 1
nd = 2 #Number of dimensions, 2 for plane-strain, and 3 for 3D analysis.
rho = satDensity # Saturated Soil Mass Density
op.nDMaterial('PressureIndependMultiYield', matTag, 2, satDensity, shear, bulk,
cohesion, gammaPeak, phi, refP, 0., numSurf)
print('Finished creating all soil materials....')
#-------------------------------------------------------------------------------------------
# 8. DEFINE SOIL ELEMENTS
#-------------------------------------------------------------------------------------------
#element('9_4_QuadUP', eleTag, *eleNodes, thick, matTag, bulk, fmass, hPerm, vPerm, <b1=0, b2=0>)
thick = 1.0
wgtX = 0.0
wgtY = -9.81
i = 0
n0 = 6*i
n1 = n0+1
n2 = n0+2
n3 = n0+3
n4 = n0+4
n5 = n0+5
n6 = n0+6
n7 = n0+7
n8 = n0+8
op.element('9_4_QuadUP', i, n0, n1, n2, n3, n4, n5, n6, n7, n8, thick, matTag, bulk, H2ODensity, hPerm, vPerm, wgtX, wgtY)