So I'm trying to model a metal rubber layer spring in Abaqus. I need three different angles of the layerspring. Then I create sets, partitions, surfaces and a reference point.
I try to do all of this with functions.
If I let Abaqus run my code I only get one geometry (120 degree angle) and not three like there should be. When I only let the code run until the end of Step 3, I get the three different parts with different angles.
So the problem must be in Step 4 or 5. Can someone identify my problem? Thanks in advance!
this is my code:
# Step 1: Import statements for this program
# ---------------------------------------------------------------------------------------------------------
from abaqus import *
from abaqusConstants import*
from caeModules import*
import os
import numpy as np
import math
session.journalOptions.setValues(replayGeometry=COORDINATE, recoverGeometry=COORDINATE)
DIR0 = os.path.abspath('')
TOL = 1e-6
# Step 2: Parameters used for the geometry, material, load and mesh of the rubber metal spring (N/mm/s-System is used)
# ---------------------------------------------------------------------------------------------------------
t1 = 5 # Layer thickness of the lower and upper metal layer [mm]
t2 = 10 # Layer thickness of the rubber [mm]
L = 70 # Length of the "wings" of the metal rubber spring [mm]
winkel = [120, 140, 160] # Angles of the rubber metal spring versions [Degree]
a = 120*(pi/180) # Angle of the rubber metal spring [rad]
e1 = 210000 # E-Modulus of the metal layers [MPa]
e2 = 5.5 # E-Modulus of the rubber [MPa]
v1 = 0.3 # Poisson's ratio of the metal layers []
v2 = 0.49 # Poisson's ratio of the rubber []
c = 1 # Length of the crack [mm]
C10 = 0.7083 # Coefficient for "MR" Material
C01 = 0.1417 # Coefficient for "MR" Material
D = 0.03565 # Coefficient for "MR" Material
mesh_size = 1.7 # Size of the mesh
xKraft = [10,20,30,40,50] # The x-Part of the force that is used to test the spring
yKraft = [10,20,30,40,50] # The y-Part of the force that is used to test the spring
crack_pos = 'bottom' # Use phrases "top" or "bottom" for the area of the crack
job_name = 'Crack' # This is the name of the odb file
# Model functions
# ---------------------------------------------------------------------------------------------------------
def make_geometry(model, (t1,t2,L,winkel,c), crack_pos, mesh_size) :
#draw the sketch
for w in winkel:
a = w *(pi/180)
part_name = 'spring_{}deg'.format(w)
# Step 1: The important Points of the geometry are created here and used later
# M = Middle
M0 = (0.0, 0.0)
M1 = (0, t1/cos(90*(pi/180)-(a/2)))
M2 = (0, (t1+t2)/cos(90*(pi/180)-(a/2)))
M3 = (0, (2*t1+t2)/cos(90*(pi/180)-(a/2)))
# R = Right
R0 = (L*cos(90*(pi/180)-(a/2)), L*sin(90*(pi/180)-(a/2)))
R1 = (L*cos(90*(pi/180)-(a/2))-t1*sin(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+t1*cos(90*(pi/180)-(a/2)))
R2 = (L*cos(90*(pi/180)-(a/2))-t1*sin(90*(pi/180)-(a/2))-t2*sin(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+t1*cos(90*(pi/180)-(a/2))+t2*cos(90*(pi/180)-(a/2)))
R3 = (L*cos(90*(pi/180)-(a/2))-2*t1*sin(90*(pi/180)-(a/2))-t2*sin(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+2*t1*cos(90*(pi/180)-(a/2))+t2*cos(90*(pi/180)-(a/2)))
# L = Left
L0 = (-L*cos(90*(pi/180)-(a/2)), L*sin(90*(pi/180)-(a/2)))
L1 = (-L*cos(90*(pi/180)-(a/2))+t1*sin(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+t1*cos(90*(pi/180)-(a/2)))
L2 = (-L*cos(90*(pi/180)-(a/2))+t1*sin(90*(pi/180)-(a/2))+t2*sin(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+t1*cos(90*(pi/180)-(a/2))+t2*cos(90*(pi/180)-(a/2)))
L3 = (-L*cos(90*(pi/180)-(a/2))+2*t1*sin(90*(pi/180)-(a/2))+t2*sin(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+2*t1*cos(90*(pi/180)-(a/2))+t2*cos(90*(pi/180)-(a/2)))
# C = Crack
# on the bottom of the rubber layer
C1 = (L*cos(90*(pi/180)-(a/2))-t1*sin(90*(pi/180)-(a/2))-c*cos(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+t1*cos(90*(pi/180)-(a/2))-c*sin(90*(pi/180)-(a/2)))
C11 = (L*cos(90*(pi/180)-(a/2))-t1*sin(90*(pi/180)-(a/2))-(c/2)*cos(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+t1*cos(90*(pi/180)-(a/2))-(c/2)*sin(90*(pi/180)-(a/2)),
0)
# on top of the rubber layer
C2 = (L*cos(90*(pi/180)-(a/2))-t1*sin(90*(pi/180)-(a/2))-t2*sin(90*(pi/180)-(a/2))-c*cos(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+t1*cos(90*(pi/180)-(a/2))+t2*cos(90*(pi/180)-(a/2))-c*sin(90*(pi/180)-(a/2)))
C22 = (L*cos(90*(pi/180)-(a/2))-t1*sin(90*(pi/180)-(a/2))-t2*sin(90*(pi/180)-(a/2))-(c/2)*cos(90*(pi/180)-(a/2)),
L*sin(90*(pi/180)-(a/2))+t1*cos(90*(pi/180)-(a/2))+t2*cos(90*(pi/180)-(a/2))-(c/2)*sin(90*(pi/180)-(a/2)),
0)
# Points on the lines for the creation of the sets
R00 = ((L/2)*cos(90*(pi/180)-(a/2)), (L/2)*sin(90*(pi/180)-(a/2)), 0)
L00 = (-(L/2)*cos(90*(pi/180)-(a/2)), (L/2)*sin(90*(pi/180)-(a/2)), 0)
R33 = ((L/2)*cos(90*(pi/180)-(a/2))-2*t1*sin(90*(pi/180)-(a/2))-t2*sin(90*(pi/180)-(a/2)),
(L/2)*sin(90*(pi/180)-(a/2))+2*t1*cos(90*(pi/180)-(a/2))+t2*cos(90*(pi/180)-(a/2)),
0)
L33 = (-(L/2)*cos(90*(pi/180)-(a/2))+2*t1*sin(90*(pi/180)-(a/2))+t2*sin(90*(pi/180)-(a/2)),
(L/2)*sin(90*(pi/180)-(a/2))+2*t1*cos(90*(pi/180)-(a/2))+t2*cos(90*(pi/180)-(a/2)),
0)
# Points in the middle of the faces
M00 = (0, (t1/cos(90*(pi/180)-(a/2)))/2, 0)
M11 = (0, t1/cos(90*(pi/180)-(a/2))+(t2/cos(90*(pi/180)-(a/2)))/2, 0)
M22 = (0, (t1+t2)/cos(90*(pi/180)-(a/2))+(t1/cos(90*(pi/180)-(a/2)))/2, 0)
# Step 2: Draw the sketch for the model
# ---------------------------------------------------------------------------------------------------------
s = model.ConstrainedSketch(name=part_name, sheetSize=200.0)
s.Line(point1=M0, point2=R0)
s.Line(point1=R0, point2=R1)
s.Line(point1=R1, point2=R2)
s.Line(point1=R2, point2=R3)
s.Line(point1=R3, point2=M3)
s.Line(point1=M3, point2=L3)
s.Line(point1=L3, point2=L2)
s.Line(point1=L2, point2=L1)
s.Line(point1=L1, point2=L0)
s.Line(point1=L0, point2=M0)
# Step 3: Create the part
# ---------------------------------------------------------------------------------------------------------
p = model.Part(name=part_name, dimensionality=TWO_D_PLANAR, type=DEFORMABLE_BODY)
p.BaseShell(sketch=s)
# Step 4: Create Sets, Partitions, Surfaces and Reference Points
# ---------------------------------------------------------------------------------------------------------
profile_name = 'profile_{}deg'.format(w)
p.Set(name='all', faces=p.faces[:])
p.Set(name='top', edges=p.edges.findAt((R33,), (L33,)))
p.Set(name='bottom', edges=p.edges.findAt((R00,), (L00,)))
rp = p.ReferencePoint(point=(0, 2 * t1 + t2 + 20, 0))
p.Set(name='RP', referencePoints=(p.referencePoints[rp.id],))
# Create the partition of the layers
p = model.parts[part_name]
d2 = p.faces, p.datums
s = model.ConstrainedSketch(name=profile_name, sheetSize=264.1, gridSpacing=6.6)
s.setPrimaryObject(option=SUPERIMPOSE)
p.projectReferencesOntoSketch(sketch=s, filter=COPLANAR_EDGES)
s.Line(point1=L1, point2=M1)
s.Line(point1=L2, point2=M2)
if crack_pos == 'bottom':
s.Line(point1=M2, point2=R2)
s.Line(point1=M1, point2=C1)
s.Line(point1=C1, point2=R1)
else:
s.Line(point1=M1, point2=R1)
s.Line(point1=M2, point2=C2)
s.Line(point1=C2, point2=R2)
p.PartitionFaceBySketch(faces=p.faces, sketch=s)
s.unsetPrimaryObject()
del mdb.models['Model-1'].sketches[profile_name]
if crack_pos == 'bottom':
p.Set(name='bottom-crack', edges=p.edges.findAt((C11,)))
else:
p.Set(name='top-crack', edges=p.edges.findAt((C22,)))
p.Set(name='rubber', faces=p.faces.findAt((M11,)))
p.Set(name='metal', faces=p.faces.findAt((M00,), (M22,)))
# Create the partition left and right
p = model.parts[part_name]
s = model.ConstrainedSketch(name=profile_name, sheetSize=264.1, gridSpacing=6.6)
s.setPrimaryObject(option=SUPERIMPOSE)
p.projectReferencesOntoSketch(sketch=s, filter=COPLANAR_EDGES)
# Lines for Partition
s.Line(point1=M0, point2=M3)
p.PartitionFaceBySketch(faces=p.faces, sketch=s)
s.unsetPrimaryObject()
del mdb.models['Model-1'].sketches[profile_name]
# Step 5: Create the mesh
# ---------------------------------------------------------------------------------------------------------
p.seedPart(size=mesh_size)
p.generateMesh()
return p
# One function for the whole model (create, run, evaluate)
def spring_model((t1, t2, L, winkel, c), mesh_size, crack_pos):
# Step 1: Sanity check for the variables
# ---------------------------------------------------------------------------------------------------------
if t1 < 0:
raise ValueError('The thickness of the metal layer must be positive')
if t2 < 0:
raise ValueError('The thickness of the rubber layer must be positive')
if L < 0:
raise ValueError('The length of the spring must be positive')
if (a < (pi / 4)) & (a > (pi / 2)):
raise ValueError('The angle between the two wings of the spring must be between 90 and 180 degrees')
if e1 < 0:
raise ValueError('The E-Modulus of the metal layers must be positive')
if e2 < 0:
raise ValueError('The E-Modulus of the rubber layer must be positive')
if (v1 <= 0) & (v1 >= 0.5):
raise ValueError('The Poissons ratio of the metal layers must be placed between 0 and 0.5')
if (v2 <= 0) & (v1 >= 0.5):
raise ValueError('The Poissons ratio of the rubber layer must be placed between 0 and 0.5')
# reset the model
Mdb()
model = mdb.models['Model-1']
# make the parts, mesh it and return it
p = make_geometry(model, (t1, t2, L, winkel, c), crack_pos, mesh_size)
return model
model = spring_model((t1, t2, L, winkel, c), mesh_size, crack_pos)
So, with the caveat that I do not knowing anything about "abaqus", here is my best guess.
On about line 38 you start a for
loop over your "winkels" which also appear to be your angles:
winkel = [120, 140, 160] # Angles of the rubber metal spring versions [Degree]
However, after processing each step for the first "winkle", in step 5 you exit the method make_geometry()
without processing either the second or third "winkle"
def make_geometry(model, (t1,t2,L,winkel,c), crack_pos, mesh_size) :
for w in winkel:
a = w *(pi/180)
part_name = 'spring_{}deg'.format(w)
# Step 1: The important Points of the geometry are created here and used later
...
# Step 2: Draw the sketch for the model
...
# Step 3: Create the part
...
# Step 4: Create Sets, Partitions, Surfaces and Reference Points
...
# Step 5: Create the mesh
p.seedPart(size=mesh_size)
p.generateMesh()
return p