source: sasview/src/sas/simulation/pointsmodelpy/tests/testcomplexmodel.py @ efa5e44

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since efa5e44 was b9a5f0e, checked in by krzywon, 10 years ago

90% complete with the conversion.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1from sasModeling.pointsmodelpy import pointsmodelpy
2from sasModeling.iqPy import iqPy
3from sasModeling.geoshapespy import geoshapespy
4
5#First testing: a normal case, a lores model holds a sphere
6#and a pdbmodel holds one pdb file. and merged into a complex
7#model, then perform calculation
8def test_complex():
9    p = pointsmodelpy.new_pdbmodel()
10    pointsmodelpy.pdbmodel_add(p,"ff0.pdb")
11
12    vp = pointsmodelpy.new_point3dvec()
13    pointsmodelpy.get_pdbpoints(p,vp);
14
15    pointsmodelpy.get_pdb_pr(p,vp)
16    pointsmodelpy.save_pdb_pr(p,"testcomplex.pr")
17
18    iq = iqPy.new_iq(100,0.001, 0.3)
19    pointsmodelpy.get_pdb_iq(p,iq)
20
21    iqPy.OutputIQ(iq,"testcomplex.iq")
22
23    a = geoshapespy.new_sphere(10)
24    lm = pointsmodelpy.new_loresmodel(0.1)
25    pointsmodelpy.lores_add(lm,a,1.0)
26
27    vpcomplex = pointsmodelpy.new_point3dvec();
28    complex = pointsmodelpy.new_complexmodel()
29    pointsmodelpy.complexmodel_add(complex,p,"PDB");
30    pointsmodelpy.complexmodel_add(complex,lm,"LORES");
31   
32    pointsmodelpy.get_complexpoints(complex,vpcomplex);
33    pointsmodelpy.get_complex_pr(complex,vpcomplex);
34    pointsmodelpy.save_complex_pr(complex,"testcomplex1.pr");
35
36    iqcomplex = iqPy.new_iq(100,0.001, 0.3)
37    pointsmodelpy.get_complex_iq(complex,iqcomplex);
38
39    iqPy.OutputIQ(iq,"testcomplex1.iq")
40
41#testing 2, insert one pdbmodel and one empty loresmodel
42def test_complex2():
43  pdb = pointsmodelpy.new_pdbmodel()
44  pointsmodelpy.pdbmodel_add(pdb,"ff0.pdb")
45
46  lores = pointsmodelpy.new_loresmodel(0.1)
47
48  complex = pointsmodelpy.new_complexmodel()   
49  pointsmodelpy.complexmodel_add(complex,pdb,"PDB");
50  pointsmodelpy.complexmodel_add(complex,lores,"LORES")
51
52  points = pointsmodelpy.new_point3dvec()
53  pointsmodelpy.get_complexpoints(complex,points)
54
55  pointsmodelpy.get_complex_pr(complex,points);
56  pointsmodelpy.save_complex_pr(complex,"testcomplex2.pr")
57
58  iqcomplex = iqPy.new_iq(100,0.001, 0.3)
59  pointsmodelpy.get_complex_iq(complex,iqcomplex)
60
61  iqPy.OutputIQ(iqcomplex,"testcomplex2.iq")
62
63  print "p(r) is saved in testcomplex2.pr"
64  print "I(Q) is saved in testcomplex2.iq"
65  print "pass"
66
67#testing 3, insert one empty pdbmodel and one loresmodel
68def test_complex3():
69  pdb = pointsmodelpy.new_pdbmodel()
70
71  lores = pointsmodelpy.new_loresmodel(0.1)
72  sph = geoshapespy.new_sphere(10)
73  pointsmodelpy.lores_add(lores,sph,1.0)
74
75  complex = pointsmodelpy.new_complexmodel()   
76  pointsmodelpy.complexmodel_add(complex,pdb,"PDB");
77  pointsmodelpy.complexmodel_add(complex,lores,"LORES")
78
79  points = pointsmodelpy.new_point3dvec()
80  pointsmodelpy.get_complexpoints(complex,points)
81
82  pointsmodelpy.get_complex_pr(complex,points);
83  pointsmodelpy.save_complex_pr(complex,"testcomplex3.pr")
84
85  iqcomplex = iqPy.new_iq(100,0.001, 0.3)
86  pointsmodelpy.get_complex_iq(complex,iqcomplex)
87
88  iqPy.OutputIQ(iqcomplex,"testcomplex3.iq")
89
90  print "p(r) is saved in testcomplex3.pr"
91  print "I(Q) is saved in testcomplex3.iq"
92  print "pass"
93
94# Test 2D complex model
95def test_complex4():
96
97
98    a = geoshapespy.new_sphere(10)
99    lm = pointsmodelpy.new_loresmodel(0.1)
100    pointsmodelpy.lores_add(lm,a,1.0)
101
102    vpcomplex = pointsmodelpy.new_point3dvec();
103    complex = pointsmodelpy.new_complexmodel()
104    pointsmodelpy.complexmodel_add(complex,lm,"LORES");
105   
106    pointsmodelpy.get_complexpoints(complex,vpcomplex);
107 
108    print pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.1,0.1);
109    print pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.01,0.1);
110
111
112if __name__ == "__main__":
113    #print "test 1, adding one nonempty loresmodel and one nonempty pdbmodel to complex model"
114    #test_complex()
115    #print "test 2, adding a nonempty pdbmodel, and adding an empty loresmodel"
116    #test_complex2()
117    #print "test 3, adding an empty pdbmodel, and adding a nonempty loresmodel"
118    #test_complex3()
119    test_complex4()
Note: See TracBrowser for help on using the repository browser.