fish杂记

初始条件

符号约定:拉为正对应max(坐标同向),压为负对应min;

fish程序的中间变量的运用很重要,要善于借助中间变量。

i = zone.state(z,bavg)

zone.state(z) = i

bavg = 1   by average    四面体体积>=50%进入塑性,该单元既显示塑性

bavg = 0   by any           四面体体积>0%进入塑性,该单元既显示塑性

fai的值与by any 一致,说明1.0fai,有一点达到屈服条件,该单元就视为屈服,fai值为1.0

偏应力不属于剪应力!一般用张量表示偏应力,张量是物理学和数学上的一个名词!
在土力学中,我们一定要搞清楚正应力、剪应力、球应力和偏应力的区别,其中正应力和剪应力属于同一种类型,叫应力分量,球应力和偏应力属于同一种类型,叫应力张量,下面我具体说来:
土体中的某一点我们可以用一个立方体表示,立方体有六个面,每一个面有一个正应力和一个剪应力,但是这个正应力和剪应力只能表示这一点在这一平面上的受力情况,那么我们如何完整表示这个立方体的整体受力状态呢?我们选择了一个3乘3的矩阵,这个矩阵我们称之为应力张量,而应力张量可以分为球应力张量和偏应力张量(这四种力的定义见我的上一个回答)
以上是理论上的回答,一般做实验用不到,你只需要记住做直接剪切实验的时候,剪力除以面积就是剪应力,而做三轴实验时,土体的竖向应力减去围压就是偏应力,它在数值上等于竖向量力环的力除以土体横截面(因为室内三轴实验受力比较特殊)

微元三个面上的主应力的平均值为西格玛m,三个主应力分别减去这个西格玛m就是偏应力,材料的体积变化取决于主应力,而进入塑性状态时形变取决于偏应力张量的状态。总而言之,偏应力张量是决定材料塑性变化的指标,张量是应力的矩阵。

1、循环获取面积,以及坐标

model new
model restore 'fai'
fish define mj
         local s0 =0 
         local s1 =0
         local s2 =0
         local s3 =0  
         local s4 =0
    loop foreach pnt zone.list
        if zone.pos.y(pnt) > 0.9 then
            if zone.pos.y(pnt) < 2.1 then
                
                if zone.extra(pnt,2) < 0.8 then
                    s0= s0 + zone.vol(pnt)
                else if zone.extra(pnt,2) < 1.6 then
                    s1= s1 + zone.vol(pnt)
                else if zone.extra(pnt,2) < 2.0 then
                    s2= s2+ zone.vol(pnt)
                else 
                    s3= s3+ zone.vol(pnt)
                endif
            endif;  matching
        endif;  matching
        
    endloop
    _mj0 = s0/1
    _mj1 = s1/1
    _mj2 = s2/1
    _mj3 = s3/1
    ii = io.out('mianji0 : '+ string(_mj0) ) ; brackets
    ii = io.out('mianji1 : '+ string(_mj1) ) 
    ii = io.out('mianji2 : '+ string(_mj2) )
    ii = io.out('mianji3 : '+ string(_mj3) ); character string + return value
    ii = io.out('total : '+ string(_mj3+_mj2+_mj1+_mj0) ) ; 
end
@mj
 model save 'mj' 

model new
model restore 'cave'
fish define _getstate
    _state = 0 
    loop foreach pnt zone.list
        if zone.pos.y(pnt) > -0.2 then
            if zone.pos.y(pnt) < 1.2 then
                ;if zone.state(pnt) # null then   ;wrong
                    _state += zone.vol(pnt)
                ;endif
            endif
        endif
    endloop
    _vol = _state/1
    ii = io.out('state_vol : ' + string(_vol))  
end
@_getstate

model new
model restore 'fai'
fish define _dianzuobiao
         ;count=0
    loop foreach pnt zone.list
        if zone.pos.y(pnt) > 0.9 then
            if zone.pos.y(pnt) < 2.1 then
                if zone.extra(pnt,2)>=0.8 then
                  if zone.extra(pnt,2) <0.99 then
                                    ;if zone.stress.max(pnt) >= -1.9e6 then
                        count += 1
                        table.x('zuobiao0.8-0.99',count) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao0.8-0.99',count) = zone.pos.z(pnt)
                        ;table.value('zuobiao11.0',count) = zone.extra(pnt,2)
                    else if zone.extra(pnt,2) <1.1 then
                        count1 += 1
                        table.x('zuobiao0.99-1.1',count1) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao0.99-1.1',count1) = zone.pos.z(pnt)
                    else if zone.extra(pnt,2) <1.9 then
                         count2 += 1
                        table.x('zuobiao1.1-1.9',count2) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao1.1-1.9',count2) = zone.pos.z(pnt)
                    else if zone.extra(pnt,2) <2.1 then
                         count3 += 1
                        table.x('zuobiao1.9-2.1',count3) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao1.9-2.1',count3) = zone.pos.z(pnt)
                    else 
                         count4 += 1
                        table.x('zuobiao2.1-',count4) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao2.1-',count4) = zone.pos.z(pnt)
                    endif
                endif
            endif
        endif
    endloop
end
@_dianzuobiao

table 'zuobiao0.8-0.99' export 'zuobiao0.8-0.99.txt'
table 'zuobiao0.99-1.1' export 'zuobiao0.99-1.1.txt'
table 'zuobiao1.1-1.9' export 'zuobiao1.1-1.9.txt'
table 'zuobiao1.9-2.1' export 'zuobiao1.9-2.1.txt'
table 'zuobiao2.1-' export 'zuobiao2.1-.txt'

model new
model restore 'fai'
fish define mj
         local s0 =0 
         local s1 =0
         local s2 =0
         local s3 =0  
         local s4 =0
    loop foreach pnt zone.list
        if zone.pos.y(pnt) > 0.9 then
            if zone.pos.y(pnt) < 2.1 then
                
                if zone.extra(pnt,2) < 0.8 then
                    s0= s0 + zone.vol(pnt)
                else if zone.extra(pnt,2) < 1.6 then
                    s1= s1 + zone.vol(pnt)
                else if zone.extra(pnt,2) < 2.0 then
                    s2= s2+ zone.vol(pnt)
                else 
                    s3= s3+ zone.vol(pnt)
                endif
            endif;  matching
        endif;  matching
        
    endloop
    _mj0 = s0/1
    _mj1 = s1/1
    _mj2 = s2/1
    _mj3 = s3/1
    ii = io.out('mianji0 : '+ string(_mj0) ) ; brackets
    ii = io.out('mianji1 : '+ string(_mj1) ) 
    ii = io.out('mianji2 : '+ string(_mj2) )
    ii = io.out('mianji3 : '+ string(_mj3) ); character string + return value
    ii = io.out('total : '+ string(_mj3+_mj2+_mj1+_mj0) ) ; 
end
@mj
 model save 'mj' 

model new
model restore 'cave'
fish define _getstate
    _state = 0 
    loop foreach pnt zone.list
        if zone.pos.y(pnt) > -0.2 then
            if zone.pos.y(pnt) < 1.2 then
                ;if zone.state(pnt) # null then   ;wrong
                    _state += zone.vol(pnt)
                ;endif
            endif
        endif
    endloop
    _vol = _state/1
    ii = io.out('state_vol : ' + string(_vol))  
end
@_getstate

model new
model restore 'fai'
fish define _dianzuobiao
         ;count=0
    loop foreach pnt zone.list
        if zone.pos.y(pnt) > 0.9 then
            if zone.pos.y(pnt) < 2.1 then
                if zone.extra(pnt,2)>=0.8 then
                  if zone.extra(pnt,2) <0.99 then
                                    ;if zone.stress.max(pnt) >= -1.9e6 then
                        count += 1
                        table.x('zuobiao0.8-0.99',count) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao0.8-0.99',count) = zone.pos.z(pnt)
                        ;table.value('zuobiao11.0',count) = zone.extra(pnt,2)
                    else if zone.extra(pnt,2) <1.1 then
                        count1 += 1
                        table.x('zuobiao0.99-1.1',count1) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao0.99-1.1',count1) = zone.pos.z(pnt)
                    else if zone.extra(pnt,2) <1.9 then
                         count2 += 1
                        table.x('zuobiao1.1-1.9',count2) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao1.1-1.9',count2) = zone.pos.z(pnt)
                    else if zone.extra(pnt,2) <2.1 then
                         count3 += 1
                        table.x('zuobiao1.9-2.1',count3) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao1.9-2.1',count3) = zone.pos.z(pnt)
                    else 
                         count4 += 1
                        table.x('zuobiao2.1-',count4) = zone.pos.x(pnt)  ;count what
                        table.y('zuobiao2.1-',count4) = zone.pos.z(pnt)
                    endif
                endif
            endif
        endif
    endloop
end
@_dianzuobiao

table 'zuobiao0.8-0.99' export 'zuobiao0.8-0.99.txt'
table 'zuobiao0.99-1.1' export 'zuobiao0.99-1.1.txt'
table 'zuobiao1.1-1.9' export 'zuobiao1.1-1.9.txt'
table 'zuobiao1.9-2.1' export 'zuobiao1.9-2.1.txt'
table 'zuobiao2.1-' export 'zuobiao2.1-.txt'

1导出全局极大值,顶部极大值、最大Z点,最大X点,

前4个函数分别获取,最后的函数统一导出

model new 
model restore 'cave8-4'

def out_max_f_glob 定义函数:输出f的全局极大值
    max_f_glob = 1  初始极大值赋值1.0
 loop foreach pnt zone.list  遍历
    f_g = zone.extra(pnt,2)    ;the value of fai  赋值给变量f_g
   if  f_g > max_f_glob         ;判断fai值与当前极大值的关系。
      max_f_glob = f_g         ; 更新当前极大值
      x_g = zone.pos.x(pnt)    ; 当前极大值的坐标点
      y_g = zone.pos.y(pnt)
      z_g = zone.pos.z(pnt)
       ;count + = 1
       ;table.x('zuobiao',count) = zone.pos.x(pnt)
       ;table.y('zuobiao',count) = zone.pos.z(pnt)
   endif
 endloop   结束循环
end   
 @out_max_f_glob   使用函数
;table 'zuobiao' export 'zuobiao3.txt' (wait the fun run over)
;model new 
;model restore 'cave2-4'

def out_max_up    定义函数:导出fai顶部极大值
    max_f_up = 1   初始值为1.0
 loop foreach pnt zone.list   遍历单元
   if zone.pos.x(pnt) >79 then    限定寻找范围
     if zone.pos.x(pnt) < 81.0 then    ;define the calculate area 
       z_up = zone.extra(pnt,2)   将fai值赋给变量z_up
        if  z_up > max_f_up     如果变量的值大于当前极大值
          max_f_up = z_up     更新当前极大值
          x1 = zone.pos.x(pnt)  并给出当前极大值的坐标
          y1 = zone.pos.y(pnt)
          z1 = zone.pos.z(pnt)
          endif
      endif
    endif 
 endloop  结束循环
end
@out_max_up   执行函数
print   输出极大值

;model new 
;model restore 'cave2-4'
def out_max_zpos    定义函数:导出极大 z坐标
    max_z = 1
 loop foreach pnt zone.list
 
   if zone.pos.x(pnt) >70.0 then  判断x的范围
   if zone.pos.x(pnt) <90.0 then
     if zone.extra(pnt,2) >=0.999 then  在判断fai的取值范围
     ;if zone.extra(pnt,2) >=1.999 then
       z_1 = zone.pos.z(pnt)         ;fai塑性区的最高点z
        if  z_1 > max_z
           max_z = z_1    找到极大z
          x1 = zone.pos.x(pnt)  导出改点坐标
          y1 = zone.pos.y(pnt)
          z1 = zone.pos.z(pnt)
          endif
        endif 
 endif
endif
 endloop
end
@out_max_zpos

   
;model new 
;model restore 'cave2-4'
def out_max_xpos    定义函数,导出最大 x 坐标
    max_x = 1
 loop foreach pnt zone.list
   ;if zone.pos.x(pnt) <79.0 then
   if zone.pos.x(pnt) >81.0 then 
     if zone.extra(pnt,2) >=0.999 then
     ;if zone.extra(pnt,2) >=1.999 then
       x_1 = zone.pos.x(pnt)
        if  x_1 > max_x
           max_x = x_1 
          x1 = zone.pos.x(pnt)
          y1 = zone.pos.y(pnt)
          z1 = zone.pos.z(pnt)
          x0 = math.abs(x1- 81)
          endif
        endif 
 ;endif
endif
 endloop
end
@out_max_xpos

def out_data  ; (just for output specific data)   定义函数:导出特定数据
  zone_num = 4  ;(zone.num)   4个数据
  file_infp = array.create(zone_num+1) ;(creat 4+1=5 line)
  
  count =1  ; (the two line are for outputing title in the first row  
  file_infp(count) = "maxf    x         z2            zup"       ;(space for this and for %1234 is used for data interval  digits
  
  count+=1  ;(avoid covering the title )
    ;loop foreach pnt zone.list
    ;if  zone.pos.y(pnt) = 1.5         
       file_infp(count) = string.build("%1         %2        %3          %4", ...
                        max_f_glob,max_x, max_z,max_f_up)  ;(build fun is the core)
       ; count+=1  ;( this is used for match loop function to output each zone
   ; endif
   ; endloop
   
  outflag = file.open("zone_out.txt",1,1) ;(open new file)
  file.write (file_infp,zone_num+1)       ;(write the data)
  file.close()                            ;(save the file)
end
@out_data
 


  

model new 
model restore 'cave8-4'

def out_max_f_glob   定义函数:输出f 全局极大值
    max_f_glob = 1  初始极大值设置为1
 loop foreach pnt zone.list 遍历zone
    f_g = zone.extra(pnt,2)    ;the value of fai 赋值给变量f_g
   if  f_g > max_f_glob ;
      max_f_glob = f_g         ;the global area mx
      x_g = zone.pos.x(pnt)
      y_g = zone.pos.y(pnt)
      z_g = zone.pos.z(pnt)
       ;count + = 1
       ;table.x('zuobiao',count) = zone.pos.x(pnt)
       ;table.y('zuobiao',count) = zone.pos.z(pnt)
   endif
 endloop
end
 @out_max_f_glob
;table 'zuobiao' export 'zuobiao3.txt' (wait the fun run over)
;model new 
;model restore 'cave2-4'
def out_max_up
    max_f_up = 1
 loop foreach pnt zone.list
   if zone.pos.x(pnt) >79 then
     if zone.pos.x(pnt) < 81.0 then    ;define the calculate area 
       z_up = zone.extra(pnt,2) 
        if  z_up > max_f_up 
          max_f_up = z_up 
          x1 = zone.pos.x(pnt)
          y1 = zone.pos.y(pnt)
          z1 = zone.pos.z(pnt)
          endif
      endif
    endif 
 endloop
end
@out_max_up
print 

;model new 
;model restore 'cave2-4'
def out_max_zpos
    max_z = 1
 loop foreach pnt zone.list
 
   if zone.pos.x(pnt) >70.0 then
   if zone.pos.x(pnt) <90.0 then
     if zone.extra(pnt,2) >=0.999 then
     ;if zone.extra(pnt,2) >=1.999 then
       z_1 = zone.pos.z(pnt)         ;the  mx_pos of fai=1.0
        if  z_1 > max_z
           max_z = z_1 
          x1 = zone.pos.x(pnt)
          y1 = zone.pos.y(pnt)
          z1 = zone.pos.z(pnt)
          endif
        endif 
 endif
endif
 endloop
end
@out_max_zpos

   
;model new 
;model restore 'cave2-4'
def out_max_xpos
    max_x = 1
 loop foreach pnt zone.list
   ;if zone.pos.x(pnt) <79.0 then
   if zone.pos.x(pnt) >81.0 then 
     if zone.extra(pnt,2) >=0.999 then
     ;if zone.extra(pnt,2) >=1.999 then
       x_1 = zone.pos.x(pnt)
        if  x_1 > max_x
           max_x = x_1 
          x1 = zone.pos.x(pnt)
          y1 = zone.pos.y(pnt)
          z1 = zone.pos.z(pnt)
          x0 = math.abs(x1- 81)
          endif
        endif 
 ;endif
endif
 endloop
end
@out_max_xpos

def out_data  ; (just for output specific data)
  zone_num = 4  ;(zone.num)
  file_infp = array.create(zone_num+1) ;(creat 4+1=5 line
  
  count =1  ; (the two line are for outputing title in the first row
  file_infp(count) = "maxf    x         z2            zup"       ;(space for this and for %1234 is used for data interval  digits
  
  count+=1  ;(avoid covering the title )
    ;loop foreach pnt zone.list
    ;if  zone.pos.y(pnt) = 1.5         
       file_infp(count) = string.build("%1         %2        %3          %4", ...
                        max_f_glob,max_x, max_z,max_f_up)  ;(build fun is the core)
       ; count+=1  ;( this is used for match loop function to output each zone
   ; endif
   ; endloop
   
  outflag = file.open("zone_out.txt",1,1) ;(open new file)
  file.write (file_infp,zone_num+1)       ;(write the data)
  file.close()                            ;(save the file)
end
@out_data
 


  

 1导出界面所有单元的FAI,以及对应的坐标点。导出函数的一些改编。

def out_data  ; (just for output specific data) 修改为特定用途函数
  zone_num = 4  ;(zone.num)  单元数(如果要导出每一个单元,zone.num);也可以拟定
  file_infp = array.create(zone_num+1) ;(creat 4+1=5 line) 5行(以上一行给定的数量为基础,增加一行作为表头)
  
  count =1  ; (the two line are for outputing title in the first row    写下第一行表头如下)
  file_infp(count) = "maxf    x         z2            zup"       ;(space for this and for %1234 is used for data interval  digits
  
  count+=1  ;(avoid covering the title )   从第二行开始,填写具体数据
    ;loop foreach pnt zone.list
    ;if  zone.pos.y(pnt) = 1.5         
       file_infp(count) = string.build("%1         %2        %3          %4", ...
                        max_f_glob,max_x, max_z,max_f_up)  ;(build fun is the core)
       ; count+=1  ;( this is used for match loop function to output each zone
   ; endif
   ; endloop
   
  outflag = file.open("zone_out.txt",1,1) ;(open new file)
  file.write (file_infp,zone_num+1)       ;(write the data)
  file.close()                            ;(save the file)
end
@out_data
 

def outpos     原函数
  zone_num = zone.num   单元数量
  file_infp = array.create(zone_num +1)  总行数要比单元总数多一,以第一行作为表头行。
  count =1 
  file_infp(count) = "id     xpos                  zpos                  fai"       ;space is used for data interval  digits
  count+=1
    loop foreach pnt zone.list
    if  zone.pos.y(pnt) = 1.5         
       file_infp(count) = string.build("%1         %2             %3                 %4",zone.id(pnt),zone.pos.x(pnt), zone.pos.z(pnt),zone.extra(pnt,2)) 
        count+=1
    endif
    endloop
  outflag = file.open("zone_pos_12-4_11.txt",1,1)
  file.write (file_infp,zone_num+1)
  file.close()
end
@outpos
 

model new 
model restore 'cave12-4_11'

def outpos
  zone_num = zone.num
  file_infp = array.create(zone_num +1)
  count =1 
  file_infp(count) = "id     xpos                  zpos                  fai"       ;space is used for data interval  digits
  count+=1
    loop foreach pnt zone.list
    if  zone.pos.y(pnt) = 1.5         
       file_infp(count) = string.build("%1         %2             %3                 %4",zone.id(pnt),zone.pos.x(pnt), zone.pos.z(pnt),zone.extra(pnt,2)) 
        count+=1
    endif
    endloop
  outflag = file.open("zone_pos_12-4_11.txt",1,1)
  file.write (file_infp,zone_num+1)
  file.close()
end
@outpos
 

 顶部、两帮、全局、底部

model new 
model restore 'cave40-1.5'

def out_max_f_glob 
    max_f_glob = 1
 loop foreach pnt zone.list
    f_g = zone.extra(pnt,2)    ;the value of fai
   
   if  f_g > max_f_glob 
      max_f_glob = f_g         ;the global area mx
      x_g = zone.pos.x(pnt)
      y_g = zone.pos.y(pnt)
      z_g = zone.pos.z(pnt)
       ;count + = 1
       ;table.x('zuobiao',count) = zone.pos.x(pnt)
       ;table.y('zuobiao',count) = zone.pos.z(pnt)
   endif
 endloop
end
 @out_max_f_glob
;table 'zuobiao' export 'zuobiao3.txt' ;(wait the fun run over)
;model new 
;model restore 'cave2-4'
def out_max_up
    max_f_up = 1
 loop foreach pnt zone.list
   if zone.pos.z(pnt) >=81.9 then
   ;if zone.pos.x(pnt) <90.0 then   ;define the calculate area 
       z_up = zone.extra(pnt,2) 
        if  z_up > max_f_up 
          max_f_up = z_up 
          xu = zone.pos.x(pnt)
          yu = zone.pos.y(pnt)
          zu = zone.pos.z(pnt)
        endif
      ;endif
    endif 
 endloop
end
@out_max_up


;model new 
;model restore 'cave2-4'
def out_max_ins
    max_ins = 1
 loop foreach pnt zone.list
 
   if zone.pos.z(pnt) >=77.9 then
   if zone.pos.z(pnt) <81.9 then
     ;if zone.extra(pnt,2) >=0.999 then
     ;if zone.extra(pnt,2) >=1.999 then
       f_ins = zone.extra(pnt,2)         ;the  mx_pos of fai=1.0
        if  f_ins> max_ins
           max_ins = f_ins
          x1 = zone.pos.x(pnt)
          y1 = zone.pos.y(pnt)
          z1 = zone.pos.z(pnt)
        endif
    endif 
    endif
;endif
 endloop
end
@out_max_ins
   
;model new 
;model restore 'cave2-4'
;def out_max_xpos
 ;   max_x = 1
; loop foreach pnt zone.list
   ;if zone.pos.x(pnt) <79.0 then
  ; if zone.pos.x(pnt) >81.0 then 
   ;  if zone.extra(pnt,2) >=0.999 then
     ;if zone.extra(pnt,2) >=1.999 then
    ;   x_1 = zone.pos.x(pnt)
   ;     if  x_1 > max_x
    ;       max_x = x_1 
    ;      x1 = zone.pos.x(pnt)
    ;      y1 = zone.pos.y(pnt)
     ;     z1 = zone.pos.z(pnt)
      ;    x0 = math.abs(x1- 81)
       ;   endif
        ;endif 
 ;endif
;endif
 ;endloop
;end
;@out_max_xpos

def out_data  ; (just for output specific data)
  zone_num = 1  ;(zone.num)
  file_infp = array.create(zone_num+1) ;(creat 4+1=5 line
  
  count =1  ; (the two line are for outputing title in the first row
  file_infp(count) = "maxf      max_ins       max_up"       ;(space for this and for %1234 is used for data interval  digits
  
  count+=1  ;(avoid covering the title )
    ;loop foreach pnt zone.list
    ;if  zone.pos.y(pnt) = 1.5         
       file_infp(count) = string.build("%1         %2        %3       " , ...
                        max_f_glob,max_ins, max_f_up)  ;(build fun is the core)
       ; count+=1  ;( this is used for match loop function to output each zone
   ; endif
   ; endloop
   
  outflag = file.open("out40_3.txt",1,1) ;(open new file)
  file.write (file_infp,zone_num+1)       ;(write the data)
  file.close()                            ;(save the file)
end
@out_data
 


  

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值