- 积分
- 0
- 注册时间
- 2012-11-19
- 仿真币
-
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2013-1-11 10:40:03
|
显示全部楼层
来自 河南郑州
;fname: CAD_support.fis
;
; Itasca Consulting Group, Inc.
; ===========================================================================
; Support functions for CAD Examples for PFC3D
;
; -------------------------------------------
;---------------- STL Support functions -------------
;----------
; setArray
;----------
def setArray
array arr(60000) xtri(19000,3) ytri(19000,3) ztri(19000,3)
end
;----------
; Reads and ASCII STL file composed of triangles
;----------
def readStlFile
wl_ = max_wid
command
set echo off
end_command
oo = open(fn_stl,0,1)
nret = read(arr,60000)
oo = out(' Lines input = '+string(nret))
oo = close
ntri = 0
loop n (1,nret)
if InTriangle = 1
if parse(arr(n),1) = 'vertex'
nver = nver + 1
xtri(ntri,nver) = parse(arr(n),2)
ytri(ntri,nver) = parse(arr(n),3)
ztri(ntri,nver) = parse(arr(n),4)
endif
if parse(arr(n),1) = 'endloop'
InTriangle = 0
endif
else
if parse(arr(n),1) = 'outer'
InTriangle = 1
ntri = ntri + 1
nver = 0
endif
endif
endLoop
oo = out(' Triangles = '+string(ntri))
loop n (1,ntri)
x1 = xtri(n,1)
y1 = ytri(n,1)
z1 = ztri(n,1)
x_ = x1
y_ = y1
z_ = z1
getMaxMin
x2 = xtri(n,2)
y2 = ytri(n,2)
z2 = ztri(n,2)
x_ = x2
y_ = y2
z_ = z2
getMaxMin
x3 = xtri(n,3)
y3 = ytri(n,3)
z3 = ztri(n,3)
x_ = x3
y_ = y3
z_ = z3
getMaxMin
command
wall face x1 y1 z1 x2 y2 z2 x3 y3 z3
endCommand
endLoop
command
set echo on
end_command
; Below, we associate the color wcolor_ to all the walls of the newly
; read object
wu_ = max_wid
_iniWallColor
wcolor_ = wcolor_ + 1
end
;-----------
; getMaxMin
;-----------
def getMaxMin
if x_ > x_max
x_max = x_
end_if
if y_ > y_max
y_max = y_
end_if
if z_ > z_max
z_max = z_
end_if
if x_ < x_min
x_min = x_
end_if
if y_ < y_min
y_min = y_
end_if
if z_ < z_min
z_min = z_
end_if
end
;-----------
; _iniWallColor
;-----------
def _iniWallColor
wu_ = wu_
wl_ = wl_
wcolor_ = wcolor_
wp_ = wall_head
loop while wp_ # null
if w_id(wp_) <= wu_
if w_id(wp_) > wl_
w_color(wp_) = wcolor_
endif
endif
wp_ = w_next(wp_)
endloop
end
;---------------- Simulation Support functions -------------
def simini
command
set random
; set local damping to zero in order to allow unimpeded free flight
damp default local 0.0
; activate viscous damping
damp default viscous normal 0.7 notens on shear 0.7
; When PFC3D knows that there will be no more than 20,000 balls, it can optimize
; its search algorithm accordingly
set max_balls 20000
; PFC3D won't stop with an error message if it cannot pack all the balls we are
; asking it to generate
set gen_error off
end_command
filename = 'test'
time_sav = 0.
dt_sav = 1e-1
end
def simloop
msg = 'The simulation will now start and\ncreate a number of SAV files.'
msg = msg + '\nThese files can then be used by\nPFC3D or Iv to generate animations.'
o = msgbox(msg,'Start of simulation',1)
loop _i (0,500)
if _i < 10
_zeros = '000'
else
if _i < 100
_zeros = '00'
else
_zeros = '0'
endif
endif
_file = string(filename) + string(_zeros) + string(_i)
command
; setting ratio to a small value forces PFC3D to continue stepping in time
; until time_sav is reached
solve time time_sav ratio 1.e-8
colorBallsBasedOnVelocity
save _file
endcommand
time_sav = time_sav + dt_sav
endloop
end
def _iniWallVel
command
wall prop x 0. y 0. z 0.
set echo off
end_command
wp_ = wall_head
loop while wp_ # null
if w_color ( wp_ ) = 0
wid = w_id ( wp_ )
w_xvel ( wp_ ) = wxvel_
w_yvel ( wp_ ) = wyvel_
w_zvel ( wp_ ) = wzvel_
w_rxvel ( wp_ ) = wrxvel_
w_ryvel ( wp_ ) = wryvel_
w_rzvel ( wp_ ) = wrzvel_
endif
wp_ = w_next ( wp_ )
endloop
command
set echo on
end_command
end
;---------------- Plotting Support functions -------------
def colorBallsBasedOnVelocity
if flg_colorBallsBasedOnVel # 0 then
vmin = 0.
vmax = 2
bp_ = ball_head
loop while bp_ # null
bvmag = b_xvel(bp_) * b_xvel(bp_)
bvmag = bvmag + b_yvel(bp_) * b_yvel(bp_)
bvmag = bvmag + b_zvel(bp_) * b_zvel(bp_)
bvmag = sqrt (bvmag)
b_color(bp_) = int(((bvmag - vmin)/vmax)* 16.)
bp_ = b_next(bp_)
endloop
endif
end
;-----------
; plotWalls
;-----------
def plotWalls
wcolor_last = wcolor_ - 1
loop counter_ ( 0, wcolor_last - 1 )
command
pl add wall range col counter_
end_command
endloop
command
pl add wall range col wcolor_last transp 80
end_command
end
define plot_view
command
plot create the_system
end_command
plotWalls
command
pl add ball orange lgreen
pl set perspective off
pl set background white
pl set caption off
pl show
end_command
end
; ===========================================================================
; EoF : CAD_support.fis
;fname: STR.DAT
;
; Itasca Consulting Group, Inc.
; ===========================================================================
; Importing CAD geometry data in PFC3D
; Stirred Tank Reactor example
; -------------------------------------------
new
; Load support function
call ../CAD_support.fis
;--------------
; makeAssembly
;--------------
def makeAssembly
dens_b = 1000.0
s_stiff = 2.0e7
n_stiff = 2.0e7
s_stiffw = 2.0e7
n_stiffw = 2.0e7
x_min = 0.65
x_max = 2.15
y_min = 0.65
y_max = 2.15
z_min = -2.29
z_max = 2.29
r1 = 0.075
; --- Create assembly ---
; We create 4 set of balls in 2 colors
num1 = 0
num2 = 0
num = 500
num1 = num2 + 1
num2 = num1 + num - 1
bc = wcolor_
command
gen id=num1,num2 x=x_min,x_max y=y_min,y_max z=z_min,z_max &
rad=r1, r1
prop color bc range id num1 num2
end_command
temp = x_min
x_min = -x_max
x_max = -temp
num1 = num2 + 1
num2 = num1 + num - 1
command
gen id=num1,num2 x=x_min,x_max y=y_min,y_max z=z_min,z_max &
rad=r1, r1
prop color bc range id num1 num2
end_command
bc = wcolor_ + 1
temp = y_min
y_min = -y_max
y_max = -temp
num1 = num2 + 1 球的属性 运行的结果和形式的表达 文献(达到的什么样的结果,其他软件和离散元软件,师兄做的粮仓的达到什么样的结果)
num2 = num1 + num - 1 颗粒软件和pfc软件的学位论文
command
gen id=num1,num2 x=x_min,x_max y=y_min,y_max z=z_min,z_max &
rad=r1, r1
prop color bc range id num1 num2
end_command
temp = x_min
x_min = -x_max
x_max = -temp
num1 = num2 + 1
num2 = num1 + num - 1
command
gen id=num1,num2 x=x_min,x_max y=y_min,y_max z=z_min,z_max &
rad=r1, r1
prop color bc range id num1 num2
end_command
ii = out(string(num)+' particles were created')
end
;--------------------------- MAIN ROUTINE -----------------------------
; initialize the simulation
simini
; Read the STL files
set fn_stl = 'STRrotor.stl'
readStlFile
set fn_stl = 'STRstator.stl'
readStlFile
; Generate balls
makeAssembly
prop dens dens_b ks=s_stiff kn=n_stiff fric=0.4
wall prop ks=s_stiffw kn=n_stiffw
; set wall velocity
set wxvel_ = 0. wyvel_ = 0. wzvel_ = 0. ; translation
set wrxvel_ = 0. wryvel_ = 0. wrzvel_ = 1.57 ; rotation
_iniWallVel
plot ball wall;新加进去的 可以显示球和墙
;set gravity
set grav 0 0 -10.0
; plot view
set pint 100
; run the simulation loop
set dt_sav = 1e-1
set flg_colorBallsBasedOnVel = 0
simloop
; -------------------------------------------
return
; ===========================================================================
; EoF : STR.dat
运行后的图形有点不好 不知道怎么改的 有没有哪位大虾可以指教的 不胜感谢 |
|