幻影生成
phantombuild的Python项目详细描述
幻像构建
phantom-build is designed to make building Phantom easier.
其主要目的是建立可复制的Phantom结构,用于编写可复制的论文。
安装
使用pip安装幻像构建
pip install phantombuild
用法
导入幻像生成
>>>importphantombuildaspb
幻像构建有四个主要功能:
get_phantom
用于从bitbucket repository克隆幻象,或检查它是否已被克隆。checkout_phantom_version
用于签出基于git提交哈希的特定虚拟版本。patch_phantom
用于应用修补程序。build_phantom
用于编译具有特定Makefile选项的幻影
示例
可复制的幻影纸
假设你想为一张纸做一个可复制的幻影模型。您希望从特定版本的Phantom开始工作,并且需要对该版本应用修补程序
首先,克隆幽灵
# Clone Phantomphantom_dir=pathlib.Path('~/repos/phantom').expanduser()pb.get_phantom(phantom_dir)
现在,查看基于git提交散列的phantom的特定版本。
# Checkout particular commitrequired_phantom_git_commit_hash='6666c55feea1887b2fd8bb87fbe3c2878ba54ed7'pb.checkout_phantom_version(phantom_dir,required_phantom_git_commit_hash)
然后,敷上你的贴片
# Apply patchphantom_patch=pathlib.Path('my-phantom.patch')pb.patch_phantom(phantom_dir,phantom_patch)
现在,使用特定的makefile选项构建幻影。
# Makefile optionssetup='dustybox'system='gfortran'extra_makefile_options={'MAXP':'10000000'}hdf5_location=pathlib.Path('/usr/local/opt/hdf5')# Compile Phantompb.build_phantom(phantom_dir,setup,system,hdf5_location,extra_makefile_options)
您可以将上述内容写入git文档库附带的脚本中,以帮助您的文档具有可复制性当然,您还需要包含所有幻影文件.in
和.setup
有关管理这些文件的信息,请参见phantom-config。