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


Python SphereModel.set_dispersion方法代码示例

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


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

示例1: TestSphere

# 需要导入模块: from sas.models.SphereModel import SphereModel [as 别名]
# 或者: from sas.models.SphereModel.SphereModel import set_dispersion [as 别名]
class TestSphere(unittest.TestCase):
    """
        Testing C++ Cylinder model
    """
    def setUp(self):
        from sas.models.SphereModel import SphereModel
        self.model= SphereModel()
        
        self.model.setParam('scale', 1.0)
        self.model.setParam('radius', 60.0)
        self.model.setParam('sldSph', 2.0)
        self.model.setParam('sldSolv', 1.0)
        self.model.setParam('background', 0.0)
        
    def test_simple(self):
        """
            Test simple 1D and 2D values
            Numbers taken from model that passed validation, before
            the update to C++ underlying class.
        """
        self.assertTrue(math.fabs(self.model.run(0.001)-90412744456148.094)<=50.0)
        self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 
                               90347660670656.391, 1)

    def test_dispersion(self):
        """
            Test with dispersion
        """
        from sas.models.DisperseModel import DisperseModel
        disp = DisperseModel(self.model, ['radius'], [10])
        disp.setParam('n_pts', 10)
        disp.setParam('radius.npts', 10)
        disp.setParam('radius.nsigmas', 2.5)
        self.assertTrue(math.fabs(disp.run(0.001)-96795008379475.219<50.0))
        
    def test_new_disp(self):
        from sas.models.dispersion_models import GaussianDispersion
        disp_rm = GaussianDispersion()
        self.model.set_dispersion('radius', disp_rm)
        self.model.dispersion['radius']['width'] = 0.1666666667
        self.model.dispersion['radius']['npts'] = 10
        self.model.dispersion['radius']['nsigmas'] = 2
开发者ID:ricleal,项目名称:SasModeling,代码行数:44,代码来源:utest_dispersity.py

示例2: TestSphereGauss

# 需要导入模块: from sas.models.SphereModel import SphereModel [as 别名]
# 或者: from sas.models.SphereModel.SphereModel import set_dispersion [as 别名]
class TestSphereGauss(unittest.TestCase):
    """
        Testing C++  Polydispersion w/ sphere comparing to IGOR/NIST computation
    """
    def setUp(self):
        loader = Loader()
        ## IGOR/NIST computation
        self.output_gauss=loader.load('Gausssphere.txt')
        self.output_shulz=loader.load('Schulzsphere.txt')

        from sas.models.SphereModel import SphereModel
        self.model= SphereModel()

        self.model.setParam('scale', 0.01)
        self.model.setParam('radius', 60.0)
        self.model.setParam('sldSph', 1.e-6)
        self.model.setParam('sldSolv', 3.e-6)
        self.model.setParam('background', 0.001)

    def test_gauss(self):
        from sas.models.dispersion_models import GaussianDispersion
        disp_g = GaussianDispersion()
        self.model.set_dispersion('radius', disp_g)
        self.model.dispersion['radius']['width'] = 0.2
        self.model.dispersion['radius']['npts'] = 100
        self.model.dispersion['radius']['nsigmas'] = 10
        for ind in range(len(self.output_gauss.x)):
            self.assertAlmostEqual(self.model.run(self.output_gauss.x[ind]), 
                                   self.output_gauss.y[ind], 2)
        
    def test_shulz(self):
        from sas.models.dispersion_models import SchulzDispersion
        disp_s = SchulzDispersion()
        self.model.set_dispersion('radius', disp_s)
        self.model.dispersion['radius']['width'] = 0.2
        self.model.dispersion['radius']['npts'] = 100
        self.model.dispersion['radius']['nsigmas'] = 10
        for ind in range(len(self.output_shulz.x)):
            self.assertAlmostEqual(self.model.run(self.output_gauss.x[ind]), 
                                   self.output_shulz.y[ind], 3)        
开发者ID:ricleal,项目名称:SasModeling,代码行数:42,代码来源:utest_sphere_dispersity.py


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