particle_fields.py 文件源码

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

项目:yt 作者: yt-project 项目源码 文件源码
def particle_vector_functions(ptype, coord_names, vel_names, registry):

    unit_system = registry.ds.unit_system

    # This will column_stack a set of scalars to create vector fields.

    def _get_vec_func(_ptype, names):
        def particle_vectors(field, data):
            v = [data[_ptype, name].in_units(field.units)
                  for name in names]
            c = np.column_stack(v)
            return data.apply_units(c, field.units)
        return particle_vectors
    registry.add_field((ptype, "particle_position"),
                       sampling_type="particle",
                       function=_get_vec_func(ptype, coord_names),
                       units = "code_length")
    registry.add_field((ptype, "particle_velocity"),
                       sampling_type="particle",
                       function=_get_vec_func(ptype, vel_names),
                       units = unit_system["velocity"])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号