Gekko化学库可用组分列表查询及compounds.txt文件定位问题
Gekko化学库可用组分列表获取方法
方法一:切换本地模式获取compounds.txt文件
你之前使用remote=True会将计算任务提交到远程服务器,compounds.txt会生成在远程服务器而非本地,所以无法找到。切换到本地模式即可在本地生成该文件:
- 修改代码中的
remote参数为False,并启用m.open_folder():
from gekko import GEKKO, chemical m = GEKKO(remote=False) # 切换本地模式 c = chemical.Properties(m) # 触发组分查找报错(自动生成compounds.txt) try: c.compound('Na2SO4') mw = c.thermo('mw') m.solve(disp=False) except: pass m.open_folder() # 打开本地工作目录
- 打开的文件夹中就能找到
compounds.txt,里面列出了所有111种可用组分。
方法二:直接通过API打印可用组分列表
无需运行求解器,直接调用Gekko化学模块的内置方法即可查看所有可用组分:
from gekko import chemical # 打印所有可用组分 print(chemical.compounds())
内容的提问来源于stack exchange,提问作者Claquettes-Sandales
相关产品推荐
相关产品推荐

