Changes between Version 22 and Version 23 of FAQ

Jan 13, 2011, 3:14:53 PM (10 years ago)



  • FAQ

    v22 v23  
    1515'''[#WhydoesSimulationappeartohangorslowdownforlargespinsystems Why does Simulation appear to hang or slow down for large spin systems?]'''
     17'''[#MyPYGAMMAProgramIsUnstableorBehavesBadlyandYetitLooksFine My PYGAMMA Program Is Unstable or Behaves Badly and Yet it Looks Fine?]'''
    3638Note: The time it takes to run these specific jobs is virtually identical in GAMMA versus Simulation - as there is little overhead (e.g. converting arrays between python and C++) when compared to the overall time of the calculations.
     40=== My PYGAMMA Program Is Unstable or Behaves Badly and Yet it Looks Fine? ===
     41Under certain circumstances your pyGamma code can be written in perfectly good Python style yet give unpredictable errors (or no error at all). This is caused by the default behavior of SWIG when applied to C++ code to create Python interfaces. If you have written code that involves subroutines, like this pseudocode,
     43import pygamma as pg
     45def binning()
     46   # do something interesting
     47   pass
     49def my_pulse_sequence()
     50    sys = pg.spin_system()
     51    # do something else interesting
     52    ACQ = pg.acquire1D(pygamma.gen_op(D), H, 0.000001)
     53    mx = ACQ.table(sigma0)
     54    return mx
     56mxa = my_pulse_sequence()
     58# About to have a problem...
     59binning(mxa, field, spin_count)
     62You are at risk of having one of a number of problems. This is because mxa points to a an object that is contained within another object that has been made available for deletion. So far we have see these errors:
     64    * Segfault
     65    * Bus Errors
     66    * Pointers to uninitialized data
     67    * An error box saying something bad happened
     68    * Pointer to the correct value with no notification that it may not be valid the next time you look
     70We list here a [gamma:SwigIssueSegfault detailed description of the problem and suggest some work arounds].
     72In this example we are returning a transition table (TTable1D), which is an object that is contained within ACQ, an acquire1D object. The