_write.py 文件源码

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

项目:aiida-vasp 作者: DropD 项目源码 文件源码
def _incarify(value):
    """Format value of any compatible type into the string forat appropriate for INCAR files"""
    result = None
    if isinstance(value, (str, unicode)):
        result = value
    elif not np.isscalar(value):
        value_array = np.array(value)
        shape = value_array.shape
        dim = len(shape)
        if dim == 1:
            result = ' '.join([_incarify(i) for i in value])
        elif dim == 2:
            result = '\n'.join([_incarify(i) for i in value])
        elif dim > 2:
            raise TypeError('you are trying to input a more ' +
                            'than 2-dimensional array to VASP.' +
                            'Not sure what to do...')
    elif isinstance(value, bool):
        result = '.True.' if value else '.False.'
    elif np.isreal(value):
        result = '{}'.format(value)
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号