# -*- coding: utf-8 -*-
"""
Created on 10 Jun 10 22:18:10 2021
@author: guozihao
"""
from abaqus import *
from abaqusConstants import *
import random
myModel = mdb.models['GZH']
sndc = 1.0 #水泥粒径
snvol = 0.0001 #水泥体积分数
szdc = 2.0 #沙子粒径
szvol = 0.001 #沙子体积分数
stdc = 6.0 #石头粒径
stvol = 0.01 #石头体积分数
vBa = 75.0*75.0*275.0 #基体体积
#新建基体
def basic():
s1 = myModel.ConstrainedSketch(name='__profile__', sheetSize=200.0)
s1.rectangle(point1=(-137.5, 37.5), point2=(137.5, -37.5))
p = myModel.Part(name='basic', dimensionality=THREE_D, type=DEFORMABLE_BODY)
p.BaseSolidExtrude(sketch=s1, depth=75.0)
del myModel.sketches['__profile__']
def qiu(na,a,n):
nq=na+str(n)
s1 = myModel.ConstrainedSketch(name='__profile__', sheetSize=200.0)
s1.ConstructionLine(point1=(0.0, -100.0), point2=(0.0, 100.0))
s1.ArcByCenterEnds(center=(0.0, 0.0), point1=(0.0, a/2), point2=(0.0, -a/2), direction=CLOCKWISE)
s1.Line(point1=(0.0, a/2), point2=(0.0, -a/2))
p = myModel.Part(name=nq, dimensionality=THREE_D, type=DEFORMABLE_BODY)
p.BaseSolidRevolve(sketch=s1, angle=360.0, flipRevolveDirection=OFF)
del myModel.sketches['__profile__']
def baamss():
a1 = myModel.rootAssembly
p = myModel.parts['basic']
a1.Instance(name='basic-1', part=p, dependent=ON)
def qiuamss(na,a):
a1 = myModel.rootAssembly
i = 1
while i < a+1:
p = myModel.parts[na+str(i)]
a1.Instance(name=na+str(i)+'-1', part=p, dependent=ON)
i=i+1
def translateqiu(a,b,c,na,nb,nc):
tempst = [(random.uniform(-(137.5-stdc),137.5-stdc),random.uniform(-(37.5-stdc),37.5-stdc),random.uniform(stdc/2,75-stdc))]
a1 = myModel.rootAssembly
a1.translate(instanceList=(na+'1-1', ), vector=(tempst[0][0], tempst[0][1], tempst[0][2]))
#石头填充
n=2
while n < a+1:
x = random.uniform(-(137.5-stdc),137.5-stdc)
y = random.uniform(-(37.5-stdc),37.5-stdc)
z = random.uniform(stdc/2,75-stdc)
i = 0
while i <len(tempst):
if (x-tempst[i][0])**2+(y-tempst[i][1])**2+(z-tempst[i][2])**2 >= stdc**2:
i=i+1
if i==len(tempst):
a1 = myModel.rootAssembly
a1.translate(instanceList=(na+str(n)+'-1', ), vector=(x, y, z))
n = n+1
tempst.append((x,y,z))
else:
break
#沙子填充
n=1
tempsz=[]
while n < b+1:
x = random.uniform(-(137.5-szdc),137.5-szdc)
y = random.uniform(-(37.5-szdc),37.5-szdc)
z = random.uniform(szdc/2,75-szdc)
i = 0
while i < len(tempst):
if (x-tempst[i][0])**2+(y-tempst[i][1])**2+(z-tempst[i][2])**2 >= (stdc/2+szdc/2)**2:
i=i+1
if i==len(tempst):
if len(tempsz)==0:
a1 = myModel.rootAssembly
a1.translate(instanceList=(nb+str(n)+'-1', ), vector=(x, y, z))
tempsz.append((x,y,z))
n = n+1
else:
for g in tempsz:
if (x-g[0])**2+(y-g[1])**2+(z-g[2])**2 >= (szdc/2)**2:
if g[0]==tempsz[-1][0] and g[1]==tempsz[-1][1] and g[2]==tempsz[-1][2]:
a1 = myModel.rootAssembly
a1.translate(instanceList=(nb+str(n)+'-1', ), vector=(x, y, z))
tempsz.append((x,y,z))
n = n+1
else:
break
else:
break
#水泥填充
n=1
tempsn=[]
while n < c+1:
x = random.uniform(-(137.5-sndc),137.5-sndc)
y = random.uniform(-(37.5-sndc),37.5-sndc)
z = random.uniform(sndc/2,75-sndc)
bol = 0
ist = 0
while ist < len(tempst):
if (x-tempst[ist][0])**2+(y-tempst[ist][1])**2+(z-tempst[ist][2])**2 >= (stdc/2+sndc/2)**2:
ist=ist+1
if ist==len(tempst):
bol = 1
else:
break
if bol == 1:
isz = 0
while isz < len(tempsz):
if (x-tempsz[isz][0])**2+(y-tempsz[isz][1])**2+(z-tempsz[isz][2])**2 >= (szdc/2+sndc/2)**2:
isz = isz+1
if isz==len(tempsz):
if len(tempsn)==0:
a1 = myModel.rootAssembly
a1.translate(instanceList=(nc+str(n)+'-1', ), vector=(x, y, z))
tempsn.append((x,y,z))
n = n+1
else:
for h in tempsn:
if (x-h[0])**2+(y-h[1])**2+(z-h[2])**2 >= (sndc/2)**2:
if h[0]==tempsn[-1][0] and h[1]==tempsn[-1][1] and h[2]==tempsn[-1][2]:
a1 = myModel.rootAssembly
a1.translate(instanceList=(nc+str(n)+'-1', ), vector=(x, y, z))
tempsn.append((x,y,z))
n = n+1
else:
break
else:
break
bol = 0
basic()
i1 = 1
nusn = (vBa*snvol)/((4.0/3.0)*3.14*(sndc/2)**3)
while i1 < nusn+1:
qiu('sn',sndc,i1)
i1=i1+1
i2 = 1
nusz = (vBa*szvol)/((4.0/3.0)*3.14*(szdc/2)**3)
while i2 < nusz+1:
qiu('sz',szdc,i2)
i2=i2+1
i3 = 1
nust = (vBa*stvol)/((4.0/3.0)*3.14*(stdc/2)**3)
while i3 < nust+1:
qiu('st',stdc,i3)
i3=i3+1
baamss()
qiuamss('sn',nusn)
qiuamss('sz',nusz)
qiuamss('st',nust)
translateqiu(nust,nusz,nusn,'st','sz','sn')
————————————————
版权声明:本文为CSDN博主「大黄研二必过六级」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_52439130/article/details/119854763