Changeset 8698a0d in sasmodels for sasmodels/generate.py


Ignore:
Timestamp:
Oct 17, 2017 9:53:01 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
32f87a5
Parents:
becded3
git-author:
Paul Kienzle <pkienzle@…> (10/17/17 16:23:09)
git-committer:
Paul Kienzle <pkienzle@…> (10/17/17 21:53:01)
Message:

revise api for oriented shapes, allowing jitter in the frame of the sample

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/generate.py

    r30b60d2 r8698a0d  
    714714    # Define the parameter table 
    715715    # TODO: plug in current line number 
    716     source.append('#line 542 "sasmodels/generate.py"') 
     716    source.append('#line 716 "sasmodels/generate.py"') 
    717717    source.append("#define PARAMETER_TABLE \\") 
    718718    source.append("\\\n".join(p.as_definition() 
     
    730730    source.append(call_volume) 
    731731 
    732     refs = ["_q[_i]"] + _call_pars("_v.", partable.iq_parameters) 
    733     call_iq = "#define CALL_IQ(_q,_i,_v) Iq(%s)" % (",".join(refs)) 
     732    model_refs = _call_pars("_v.", partable.iq_parameters) 
     733    pars = ",".join(["_q"] + model_refs) 
     734    call_iq = "#define CALL_IQ(_q, _v) Iq(%s)" % pars 
    734735    if _have_Iqxy(user_code) or isinstance(model_info.Iqxy, str): 
    735         # Call 2D model 
    736         refs = ["_q[2*_i]", "_q[2*_i+1]"] + _call_pars("_v.", partable.iqxy_parameters) 
    737         call_iqxy = "#define CALL_IQ(_q,_i,_v) Iqxy(%s)" % (",".join(refs)) 
     736        if partable.is_asymmetric: 
     737            pars = ",".join(["_qa", "_qb", "_qc"] + model_refs) 
     738            call_iqxy = "#define CALL_IQ_ABC(_qa,_qb,_qc,_v) Iqxy(%s)" % pars 
     739            clear_iqxy = "#undef CALL_IQ_ABC" 
     740        else: 
     741            pars = ",".join(["_qa", "_qc"] + model_refs) 
     742            call_iqxy = "#define CALL_IQ_AC(_qa,_qc,_v) Iqxy(%s)" % pars 
     743            clear_iqxy = "#undef CALL_IQ_AC" 
    738744    else: 
    739         # Call 1D model with sqrt(qx^2 + qy^2) 
    740         #warnings.warn("Creating Iqxy = Iq(sqrt(qx^2 + qy^2))") 
    741         # still defined:: refs = ["q[i]"] + _call_pars("v", iq_parameters) 
    742         pars_sqrt = ["sqrt(_q[2*_i]*_q[2*_i]+_q[2*_i+1]*_q[2*_i+1])"] + refs[1:] 
    743         call_iqxy = "#define CALL_IQ(_q,_i,_v) Iq(%s)" % (",".join(pars_sqrt)) 
     745        pars = ",".join(["_qa"] + model_refs) 
     746        call_iqxy = "#define CALL_IQ_A(_qa,_v) Iq(%s)" % pars 
     747        clear_iqxy = "#undef CALL_IQ_A" 
    744748 
    745749    magpars = [k-2 for k, p in enumerate(partable.call_parameters) 
     
    757761    # TODO: allow mixed python/opencl kernels? 
    758762 
    759     ocl = kernels(ocl_code, call_iq, call_iqxy, model_info.name) 
    760     dll = kernels(dll_code, call_iq, call_iqxy, model_info.name) 
     763    ocl = kernels(ocl_code, call_iq, call_iqxy, clear_iqxy, model_info.name) 
     764    dll = kernels(dll_code, call_iq, call_iqxy, clear_iqxy, model_info.name) 
    761765    result = { 
    762766        'dll': '\n'.join(source+dll[0]+dll[1]+dll[2]), 
     
    767771 
    768772 
    769 def kernels(kernel, call_iq, call_iqxy, name): 
     773def kernels(kernel, call_iq, call_iqxy, clear_iqxy, name): 
    770774    # type: ([str,str], str, str, str) -> List[str] 
    771775    code = kernel[0] 
     
    787791        '#line 1 "%s Iqxy"' % path, 
    788792        code, 
    789         "#undef CALL_IQ", 
     793        clear_iqxy, 
    790794        "#undef KERNEL_NAME", 
    791795    ] 
     
    798802        '#line 1 "%s Imagnetic"' % path, 
    799803        code, 
     804        clear_iqxy, 
    800805        "#undef MAGNETIC", 
    801         "#undef CALL_IQ", 
    802806        "#undef KERNEL_NAME", 
    803807    ] 
Note: See TracChangeset for help on using the changeset viewer.