Changeset 02cb31a in sasview for sansrealspace


Ignore:
Timestamp:
Sep 27, 2007 11:38:08 AM (17 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
1b0707e1
Parents:
2bb0b26
Message:

Added some 2D simulation tests.

Location:
sansrealspace/src/realspace/test
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • sansrealspace/src/realspace/test/early_test.py

    rba1d1e9 r02cb31a  
    170170        print "q=%g  sim=%g  ana=%g   ratio=%g" % (q, sim_1, ana_1, sim_1/ana_1) 
    171171 
     172def test_5(): 
     173    from sans.models.SphereModel import SphereModel 
     174    model = VolumeCanvas.VolumeCanvas() 
     175     
     176    handle = model.add('sphere') 
     177     
     178    radius = 10 
     179    density = .1 
     180     
     181    ana = SphereModel() 
     182    ana.setParam('scale', 1.0) 
     183    ana.setParam('contrast', 1.0) 
     184    ana.setParam('background', 0.0) 
     185    ana.setParam('radius', radius) 
     186     
     187    model.setParam('lores_density', density) 
     188    model.setParam('%s.radius' % handle, radius) 
     189    model.setParam('scale' , 1.0) 
     190    model.setParam('%s.contrast' % handle, 1.0) 
     191    model.setParam('background' , 0.0) 
     192     
     193    ana = ana.runXY([0.1, 0.1]) 
     194    sim = model.getIq2D(0.1, 0.1) 
     195    print ana, sim, sim/ana, ana/sim 
     196 
     197def test_6(): 
     198    from sans.models.CylinderModel import CylinderModel 
     199    radius = 5 
     200    length = 40 
     201    density = 20 
     202     
     203    ana = CylinderModel() 
     204    ana.setParam('scale', 1.0) 
     205    ana.setParam('contrast', 1.0) 
     206    ana.setParam('background', 0.0) 
     207    ana.setParam('radius', radius) 
     208    ana.setParam('length', length) 
     209     
     210    # Along Y 
     211    #ana.setParam('cyl_theta', 1.57) 
     212    #ana.setParam('cyl_phi', 1.57) 
     213     
     214    # Along Z 
     215    ana.setParam('cyl_theta', 0) 
     216    ana.setParam('cyl_phi', 0) 
     217     
     218    model = VolumeCanvas.VolumeCanvas()     
     219    handle = model.add('cylinder') 
     220    model.setParam('lores_density', density) 
     221    model.setParam('%s.radius' % handle, radius) 
     222    model.setParam('%s.length' % handle, length) 
     223    model.setParam('scale' , 1.0) 
     224    model.setParam('%s.contrast' % handle, 1.0) 
     225    model.setParam('background' , 0.0) 
     226     
     227    # Along Y 
     228    #model.setParam('%s.orientation' % handle, [0,0,0]) 
     229     
     230    # Along Z 
     231    model.setParam('%s.orientation' % handle, [1.57,0,0]) 
     232     
     233     
     234    ana = ana.runXY([0.1, 0.01]) 
     235    sim = math.pi/2*model.getIq2D(0.1, 0.01) 
     236    print model.npts 
     237    print ana, sim, sim/ana, ana/sim 
     238     
     239 
    172240     
    173241if __name__ == "__main__": 
    174     test_1() 
     242    test_6() 
Note: See TracChangeset for help on using the changeset viewer.