找回密码
 注册
Simdroid-非首页
查看: 81|回复: 5

[建模专区] 关于混合搅拌的问题请教

[复制链接]
发表于 2012-12-14 15:04:44 | 显示全部楼层 |阅读模式 来自 河南郑州
本帖最后由 binin2008 于 2012-12-14 15:09 编辑

d43424463738da86881399c7请教高手:这一种形式的语言编程是怎样的?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2012-12-14 16:04:02 | 显示全部楼层 来自 武汉大学
Simdroid开发平台
只看到3张手册里的图:L:L:L:L
回复 不支持

使用道具 举报

 楼主| 发表于 2012-12-17 10:07:35 | 显示全部楼层 来自 河南郑州
799201384 发表于 2012-12-14 16:04
只看到3张手册里的图

那有没有看到过类似的编程?主要是想知道这个用软件是怎么做到的?
回复 不支持

使用道具 举报

发表于 2012-12-17 14:30:26 | 显示全部楼层 来自 江苏镇江
就是CAD导入吖
回复 不支持

使用道具 举报

发表于 2012-12-17 16:29:20 | 显示全部楼层 来自 武汉大学
binin2008 发表于 2012-12-17 10:07
那有没有看到过类似的编程?主要是想知道这个用软件是怎么做到的?

没有看到你说的是什么语言,cad导入就是直接导入cad中自动生成的图形文件就可了,不知哪里来的语言编程
回复 不支持

使用道具 举报

 楼主| 发表于 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

运行后的图形有点不好  不知道怎么改的 有没有哪位大虾可以指教的  不胜感谢
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-9-29 07:19 , Processed in 0.040165 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表