amset.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:amset 作者: hackingmaterials 项目源码 文件源码
def to_file(self, dir_path='.', fname='amsetrun', force_write=True):
        if not force_write:
            n = 1
            fname0 = fname
            while os.path.exists(os.path.join(dir_path, '{}.json.gz'.format(fname))):
                warnings.warn('The file, {} exists. AMSET outputs will be '
                        'written in {}'.format(fname, fname0+'_'+str(n)))
                fname = fname0 + '_' + str(n)
                n += 1

        # make the output dict
        out_d = {'kgrid': self.kgrid, 'egrid': self.egrid}

        # write the output dict to file
        with gzip.GzipFile(
                os.path.join(dir_path, '{}.json.gz'.format(fname)), 'w') as fp:
            jsonstr = json.dumps(out_d, cls=MontyEncoder)
            fp.write(jsonstr)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号