예제 #1
0
def test_direct_summation():

    # correct values
    p = pdb.input(source_info='string', lines=test_pdb)
    x = p.xray_structure_simple()
    for s in x.scatterers():
        s.set_use_u(False, False)

    fc = x.structure_factors(anomalous_flag=False,
                             d_min=2.0,
                             algorithm='direct').f_calc()
    fcd = fc.data()
    indices = fc.indices()

    # test values
    xyz = x.sites_frac()
    h = flex.vec3_double(len(indices))
    fm = matrix.sqr(
        p.crystal_symmetry().unit_cell().fractionalization_matrix())
    om = matrix.sqr(
        p.crystal_symmetry().unit_cell().orthogonalization_matrix())
    for i in range(len(indices)):
        h[i] = fm * indices[i]
    sr = x.scattering_type_registry()
    st = x.scattering_types()

    sg = p.crystal_symmetry().space_group()
    r = flex.double()
    t = flex.vec3_double(len(sg))
    for i in range(len(sg)):
        r_i = om * matrix.sqr(sg[i].r().as_double())
        for a in r_i:
            r.append(a)
        t[i] = om * matrix.col(sg[i].t().as_double())

    bls = flex.double(len(xyz), 0.0)
    amplitudes = direct_summation()
    amplitudes.add(st, xyz, bls, h, r, t, sr, False)
    amplitudes = amplitudes.get_sum()

    cpu_i = flex.norm(fcd)
    gpu_i = flex.norm(amplitudes)

    mean = 0.0
    for i in range(len(cpu_i)):
        e = math.fabs(cpu_i[i] - gpu_i[i]) / cpu_i[i]
        mean += e
    mean = mean / (len(cpu_i))
    assert (mean < 1.0e-3)
def test_direct_summation():

  # correct values
  p = pdb.input(source_info='string',lines=test_pdb)
  x = p.xray_structure_simple()
  for s in x.scatterers():
    s.set_use_u(False,False)

  fc = x.structure_factors(anomalous_flag=False,d_min=2.0,
                           algorithm='direct').f_calc()
  fcd = fc.data()
  indices = fc.indices()

  # test values
  xyz = x.sites_frac()
  h = flex.vec3_double(len(indices))
  fm = matrix.sqr(p.crystal_symmetry().unit_cell().fractionalization_matrix())
  om = matrix.sqr(p.crystal_symmetry().unit_cell().orthogonalization_matrix())
  for i in xrange(len(indices)):
    h[i] = fm * indices[i]
  sr = x.scattering_type_registry()
  st = x.scattering_types()

  sg = p.crystal_symmetry().space_group()
  r = flex.double()
  t = flex.vec3_double(len(sg))
  for i in xrange(len(sg)):
    r_i = om * matrix.sqr(sg[i].r().as_double())
    for a in r_i:
      r.append(a)
    t[i] = om * matrix.col(sg[i].t().as_double())

  bls = flex.double(len(xyz),0.0)
  amplitudes = direct_summation()
  amplitudes.add(st,xyz,bls,h,r,t,sr,False)
  amplitudes = amplitudes.get_sum()

  cpu_i = flex.norm(fcd)
  gpu_i = flex.norm(amplitudes)

  mean = 0.0
  for i in xrange(len(cpu_i)):
    e = math.fabs(cpu_i[i] - gpu_i[i])/cpu_i[i]
    mean += e
  mean = mean/(len(cpu_i))
  assert(mean < 1.0e-3)
def test_saxs():

  p = pdb.input(source_info='string',lines=test_pdb)
  x = p.xray_structure_simple()
  xyz = x.sites_cart()
  blsf = flex.double(len(xyz),0.0)
  sr = x.scattering_type_registry()
  st = x.scattering_types()
  q = flex.double(range(101))/200.0

  t_w = flex.double(len(t_x),1.0)

  l = flex.double()
  l.extend(t_x)
  l.extend(t_y)
  l.extend(t_z)

  intensities = direct_summation()
  intensities.prepare_saxs(st,xyz,blsf,q,t_w,l,sr,False)
  intensities.run_saxs_kernel()
  intensities.sum_over_lattice()
  intensities = intensities.get_sum()

  assert(approx_equal(intensities[10].real,3584.9828125,out=None))
예제 #4
0
def test_saxs():

    p = pdb.input(source_info='string', lines=test_pdb)
    x = p.xray_structure_simple()
    xyz = x.sites_cart()
    blsf = flex.double(len(xyz), 0.0)
    sr = x.scattering_type_registry()
    st = x.scattering_types()
    q = flex.double(range(101)) / 200.0

    t_w = flex.double(len(t_x), 1.0)

    l = flex.double()
    l.extend(t_x)
    l.extend(t_y)
    l.extend(t_z)

    intensities = direct_summation()
    intensities.prepare_saxs(st, xyz, blsf, q, t_w, l, sr, False)
    intensities.run_saxs_kernel()
    intensities.sum_over_lattice()
    intensities = intensities.get_sum()

    assert (approx_equal(intensities[10].real, 3584.9828125, out=None))