PIPESIM Python Toolkit 系列(4):参数读取与写入——get_value 与 set_value 详解

云智设计
云智设计
云智设计
编辑
140
文章
0
粉丝
PIPESIM评论451阅读模式

模型的参数操作是 PTK 日常使用频率最高的功能。本文详解 get_valueset_valueget_valuesset_values 四大核心方法的用法。

单个参数读取:get_value()

读取油嘴的 Bean Size:文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html

from sixgill.definitions import Parameters
beansize = model.get_value(Name='Choke', parameter=Parameters.Choke.BEANSIZE)

使用字符串路径的等价写法:文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html

beansize = model.get_value('Choke', Parameters.Choke.BEANSIZE)

设置单个参数:set_value()

修改油嘴尺寸为 12/64 英寸:文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html

model.set_value(Name='Choke', parameter=Parameters.Choke.BEANSIZE, value=12)

通过高层上下文设置油藏压力——无需指定具体是哪个 Completion:文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html

model.set_value(
    Well='Well_1',
    parameter=Parameters.Completion.RESERVOIRPRESSURE,
    value='3210')

批量获取参数:get_values()

一次获取多个参数:文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html

result = model.get_values(
    Name='Choke',
    parameters=[Parameters.Choke.BEANSIZE,
                Parameters.Choke.CRITICALPRESSURERATIO])
# 返回: {'Choke': {'BeanSize': 32, 'CriticalPressureRatio': 0.55}}

获取所有油嘴的所有参数(不传参数列表即返回全部):文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html

all_params = model.get_values(Choke=ALL)

批量设置参数:set_values()

使用字典格式批量更新:文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html

updated = {
    'CentComp': {
        Parameters.Compressor.HONOURSTONEWALLLIMIT: True,
        Parameters.Compressor.EFFICIENCY: 100.0,
        Parameters.Compressor.PRESSUREDIFFERENTIAL: 2400.0
    }
}
model.set_values(updated)

统一赋值:set_all_value()

给所有油嘴设置相同的 Bean Size:文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html

model.set_all_value(Choke=ALL, parameter=Parameters.Choke.BEANSIZE, value=2)

注意:set_value() 在上下文匹配多个组件时会抛出异常,而 set_all_value() 则会对所有匹配组件执行相同赋值。文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html 文章源自云智设计-https://www.cidrg.com/cid-college/tutorial/pipesim/26888.html

云智设计应力分析服务

客服微信
扫一扫
weinxin
EngGPT
微信号已复制
云智微信公众号
扫一扫
weinxin
cidrg_com
公众号已复制
 
云智设计
  • 本文由 云智设计 发表于2026年6月7日 09:00:00
  • 本站原创文章转载请注明文章出处及链接,谢谢合作!
匿名

发表评论

匿名网友
确定

拖动滑块以完成验证