当前位置: 首页>>代码示例>>Python>>正文


Python Atom_utils._calculate_distance方法代码示例

本文整理汇总了Python中utils.Atom_utils._calculate_distance方法的典型用法代码示例。如果您正苦于以下问题:Python Atom_utils._calculate_distance方法的具体用法?Python Atom_utils._calculate_distance怎么用?Python Atom_utils._calculate_distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.Atom_utils的用法示例。


在下文中一共展示了Atom_utils._calculate_distance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _test_non_bonded_shifts

# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _calculate_distance [as 别名]
    def _test_non_bonded_shifts(self, non_bonded_potential, non_bonded_shifts):
        non_bonded_potential.update_non_bonded_list()

        target_components = non_bonded_potential._get_component_list('ATOM')
        remote_components = non_bonded_potential._get_component_list('NBRM')

        for i, component in enumerate( non_bonded_potential._get_all_components('NBLT')):

            target_component_index, remote_component_index = component[1:3]

            target_atom_id = target_components[target_component_index][0]
            remote_atom_id = remote_components[remote_component_index][0]

            expected_shift = 0.0
            key_good = False
            for j, exponent in enumerate((1,-3)):
                target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
                remote_atom_key = Atom_utils._get_atom_info_from_index(remote_atom_id)
                expected_shift_key = target_atom_key, remote_atom_key, int(exponent)
                if expected_shift_key in non_bonded_shifts:
                    expected_shift += non_bonded_shifts[expected_shift_key]
                    key_good=True
                elif j == 0:
                    distance = Atom_utils._calculate_distance(target_atom_id, remote_atom_id)
                    self.assertTrue(distance >= 5.0, expected_shift_key)

            if key_good:
                calculated_shift = non_bonded_potential._calc_component_shift(i)
                self.assertAlmostEqual(expected_shift, calculated_shift, self.DEFAULT_DECIMAL_PLACES, expected_shift_key)
开发者ID:locsmith,项目名称:xcamshift,代码行数:31,代码来源:test_xcamshift_a4.py

示例2: _test_non_bonded_forces

# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _calculate_distance [as 别名]
    def _test_non_bonded_forces(self, non_bonded_potential, non_bonded_forces, active_shifts, factors):

        components = dict(non_bonded_potential._get_components())
        nb_interaction_list = components['NBLT']
        active_array = allocate_array(1,'i')
        components['ACTI'] =  active_array
        #TODO: make this less invasive of the potentials encapsulation
        components['OFFS'] = 0
        non_bonded_potential._force_calculator._set_components(components)

        for i, component in enumerate(nb_interaction_list):
            zero_array(active_array)
            active_array[0] = i

            target_atom_id =  non_bonded_potential._get_component_list('ATOM')[component[1]][0]
            remote_atom_id =  non_bonded_potential._get_component_list('NBRM')[component[2]][0]

            target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
            remote_atom_key = Atom_utils._get_atom_info_from_index(remote_atom_id)

            if active_shifts[target_atom_key] == 0:
                continue
    #
            distance = Atom_utils._calculate_distance(target_atom_id, remote_atom_id)

            if distance  < 5.0:

                for exponent_index, exponent in enumerate((1,-3)):
                    expected_key = target_atom_key, remote_atom_key, int(exponent)
                    factor = factors[target_atom_key]

                    non_bonded_potential._force_calculator._build_component(i,exponent_index)

                    factor = factors[target_atom_key]

                    out_array = self.make_out_array()
                    non_bonded_potential._force_calculator._calc_single_force_set(0, factor,out_array)

                    forces = out_array.add_forces_to_result()
                    target_force_triplet = forces[target_atom_id]
                    remote_force_triplet  = forces[remote_atom_id]

                    expected_target_forces = non_bonded_forces[expected_key]
                    expected_remote_forces  = [-elem for elem in expected_target_forces]

                    #TODO: check change from 7 to 5 dp is ok also improve assertSequenceAlmostEqual ro take a places argument
                    self.assertSequenceAlmostEqual(target_force_triplet, expected_target_forces,delta= 1e-1**self.DEFAULT_DECIMAL_PLACES)
                    self.assertSequenceAlmostEqual(remote_force_triplet, expected_remote_forces,delta= 1e-1**self.DEFAULT_DECIMAL_PLACES)

                    atom_ids =  [target_atom_id,remote_atom_id]
                    atom_ids.sort(reverse=True)
                    for atom_id in atom_ids:
                        del forces[atom_id]
                    forces = self.remove_almost_zero_force_elems_from_list(forces)

                    self.assertEmpty(forces)

                    del non_bonded_forces[expected_key]
        self.assertEmpty(non_bonded_forces)
开发者ID:locsmith,项目名称:xcamshift,代码行数:61,代码来源:test_xcamshift_a4.py

示例3: test_non_bonded_component_shifts

# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _calculate_distance [as 别名]
    def test_non_bonded_component_shifts(self):
        xcamshift =  self._get_xcamshift()
        sub_potential = xcamshift.get_named_sub_potential(NON_BONDED)
        sub_potential.update_non_bonded_list()
        components = sub_potential._get_component_list('NBLT')
        target_atom_ids = [component[0] for component in components]
        xcamshift._prepare(TARGET_ATOM_IDS_CHANGED,target_atom_ids)
        xcamshift._prepare(ROUND_CHANGED,None)


        non_bonded_components =  dict(gb3.gb3_component_shifts_non_bonded)

        target_components = sub_potential._get_component_list('ATOM')
        remote_components = sub_potential._get_component_list('NBRM')
        for  i,(target_atom_id, target_index, remote_index, component_index) in enumerate(components):

            target_atom_id = target_components[target_index][0]
            target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)

            remote_atom_id = remote_components[remote_index][0]
            remote_atom_key =  Atom_utils._get_atom_info_from_index(remote_atom_id)


            if target_atom_key[2]== 'HA1':
                target_atom_key =  list(target_atom_key)
                target_atom_key[2]= 'HA'
                target_atom_key =  tuple(target_atom_key)



            if Atom_utils._calculate_distance(target_atom_id, remote_atom_id) > 5.0:
                continue

            shift = sub_potential._calc_component_shift(i)

            expected_shift = 0.0
            seen_keys = []
            for exponent_key in 0,1:
                non_bonded_component_key = (target_atom_key, remote_atom_key, exponent_key)
                seen_keys.append(non_bonded_component_key)
                expected_shift += non_bonded_components[non_bonded_component_key]

            self.assertAlmostEqual(shift,expected_shift,self.DEFAULT_DECIMAL_PLACES-2,`i` + ' '  + `non_bonded_component_key`)

            for seen_key in seen_keys:
                del non_bonded_components[seen_key]

        self.assertEmpty(non_bonded_components)
开发者ID:locsmith,项目名称:xcamshift,代码行数:50,代码来源:test_xcamshift_gb3.py

示例4: test_non_bonded_components

# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _calculate_distance [as 别名]
    def test_non_bonded_components(self):
        #TODO: add common loading method for xcamshift
        print 'WARNING using zero shifts with test_non_bonded_components as a hack to get _active_target_atom_ids correct!'
        xcamshift = self._setup_xcamshift_with_shifts_table(gb3.gb3_zero_shifts)
        sub_potential = xcamshift.get_named_sub_potential(NON_BONDED)
        xcamshift._prepare(TARGET_ATOM_IDS_CHANGED,None)
        xcamshift._prepare(ROUND_CHANGED,None)
        components = sub_potential._get_component_list('NBLT')


        non_bonded_components =  dict(gb3.gb3_component_shifts_non_bonded)

        target_components = sub_potential._get_component_list('ATOM')
        remote_components = sub_potential._get_component_list('NBRM')

        for  target_atom_id, target_index, remote_index, component_index in components:

            target_atom_id = target_components[target_index][0]
            target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)

            remote_atom_id = remote_components[remote_index][0]
            remote_atom_key =  Atom_utils._get_atom_info_from_index(remote_atom_id)


            if target_atom_key[2]== 'HA1':
                target_atom_key =  list(target_atom_key)
                target_atom_key[2]= 'HA'
                target_atom_key =  tuple(target_atom_key)



            if Atom_utils._calculate_distance(target_atom_id, remote_atom_id) > 5.0:
                continue

            for exponent_key in 0,1:
                non_bonded_component_key = (target_atom_key, remote_atom_key, exponent_key)

                self.assertIn(non_bonded_component_key, non_bonded_components, `non_bonded_component_key`)
                del non_bonded_components[non_bonded_component_key]

        self.assertEmpty(non_bonded_components)
开发者ID:locsmith,项目名称:xcamshift,代码行数:43,代码来源:test_xcamshift_gb3.py

示例5: _test_non_bonded_force_factors

# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _calculate_distance [as 别名]
    def _test_non_bonded_force_factors(self, non_bonded_potential, non_bonded_force_factors, active_shifts, factors):

        components = dict(non_bonded_potential._get_components())
        nb_interaction_list = components['NBLT']
        active_array = allocate_array(1,'i')
        components['ACTI'] =  active_array
        components['OFFS'] = 0
        non_bonded_potential._force_calculator._set_components(components)

        for i, component in enumerate(nb_interaction_list):
            zero_array(active_array)
            active_array[0] = i

            target_atom_id =  non_bonded_potential._get_component_list('ATOM')[component[1]][0]
            remote_atom_id =  non_bonded_potential._get_component_list('NBRM')[component[2]][0]

            target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
            remote_atom_key = Atom_utils._get_atom_info_from_index(remote_atom_id)

            if active_shifts[target_atom_key] == 0:
                continue
    #
            distance = Atom_utils._calculate_distance(target_atom_id, remote_atom_id)

            if distance  < 5.0:

                for exponent_index, exponent in enumerate((1,-3)):
                    expected_key = target_atom_key, remote_atom_key, int(exponent)
                    factor = factors[target_atom_key]

                    non_bonded_potential._force_calculator._build_component(i,exponent_index)

                    force_factor = non_bonded_potential._force_calculator._calc_single_force_factor(0, factor)
                    #TODO: check change from 7 to 5 dp is ok
                    self.assertAlmostEqual(force_factor, non_bonded_force_factors[expected_key],places=self.DEFAULT_DECIMAL_PLACES)
                    del non_bonded_force_factors[expected_key]
        self.assertEmpty(non_bonded_force_factors)
开发者ID:locsmith,项目名称:xcamshift,代码行数:39,代码来源:test_xcamshift_a4.py


注:本文中的utils.Atom_utils._calculate_distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。