2020年采用fish语言实现了结果文件间的运算,但过程涉及到文件写入写出,较为复杂。详见下文:
——
呱太Gekota,公 众号:FLAC3D小技巧位移差?应力差?利用fish语言实现结果文件间运算。
因此,本文通过python简化流程。
2.代码
model new
zone create brick size 20 20 20 group 'a'
zone group 'b' range position-x 5 15 position-z 5 15
zone gridpoint initialize pore-pressure 1e3
model save 'a'
zone gridpoint initialize pore-pressure 0 range group 'a'
model save 'b'
model restore 'a.f3sav'
fish def setup
io_read = 0
io_write = 1
io_ascii = 1
arr_size = gp.num
end
@setup
fish def pp_out
array id1(arr_size)
array pp1(arr_size)
n = 0
loop foreach gp1 gp.list
n = n+1
gp.id(gp1) =
gp.pp(gp1) =
endloop
status = file.open('id_list',io_write,io_acsii)
status = file.write(id1,string(arr_size))
status = file.close
status = file.open('pp_list',io_write,io_acsii)
status = file.write(pp1,string(arr_size))
status = file.close
end
@pp_out
model restore 'b.f3sav'
fish def setup
io_read = 0
io_write = 1
io_ascii = 1
arr_size = gp.num
end
@setup
fish def pp_minus
array id(arr_size)
array pp(arr_size)
status = file.open('id_list',io_read,io_acsii)
status = file.read(id,arr_size)
status = file.close
status = file.open('pp_list',io_read,io_acsii)
status = file.read(pp,arr_size)
status = file.close
loop i(1,arr_size)
gp = gp.find(id(i))
pp(i) - gp.pp(gp) =
endloop
end
@pp_minus
model save 'c'
;以上代码共计56行。
2.2 新代码
import itasca as it
it.command('python-reset-state false')
app = {}
bpp = {}
it.command("""
model new
model largestrain off
zone create brick size 20 20 20 group 'a'
zone group 'b' range position-x 5 15 position-z 5 15
zone gridpoint initialize pore-pressure 1e3
model save 'a'
zone gridpoint initialize pore-pressure 0 range group 'a'
model save 'b' """)
it.command(""" model restore 'a.sav """)
for gp in it.gridpoint.list():
app[gp.id()] = gp.pp()
it.command(""" model restore 'b.sav' """)
for gp in it.gridpoint.list():
bpp[gp.id()] = gp.pp()
for key in app.keys():
gp = it.gridpoint.find(key)
gp.set_pp(app[key]-bpp[key])
#以上代码共计23行。
3.结果对比
图3-1 计算结果一(2020)
图3-2 计算结果二(2023)
4.总结