Menu

Error in importing compiled vector field and integrator. Did you compile the RHS C code?

Help
2015-04-28
2015-04-29
  • Guoping Zhao

    Guoping Zhao - 2015-04-28

    Hi all,

    I'm trying to switch from Vode to Radau or Dopri integrator for my new model. But always get an error

    Error in importing compiled vector field and integrator. Did you compile the RHS C code?
    

    Here're details:

    Traceback (most recent call last):
      File "testpydstool/test1.py", line 223, in <module>
        testModel.compute(trajname='test', tdata=[0,10], ics=ics, verboselevel=1)
      File "anaconda/lib/python2.7/site-packages/PyDSTool/Model.py", line 2750, in compute
        MI, swRules)
      File "anaconda/lib/python2.7/site-packages/PyDSTool/Model.py", line 2282, in _findTrajInitiator
        self.verboselevel)
      File "anaconda/lib/python2.7/site-packages/PyDSTool/Model.py", line 3271, in findTrajInitiator
        dxdt = dict(MI.Rhs(t, icdict, pardict))
      File "anaconda/lib/python2.7/site-packages/PyDSTool/ModelContext.py", line 922, in Rhs
        return self.model.Rhs(t, xdict, pdict)
      File "anaconda/lib/python2.7/site-packages/PyDSTool/Model.py", line 1723, in Rhs
        ds.Rhs(t, x_fs, pdict))),
      File "anaconda/lib/python2.7/site-packages/PyDSTool/Generator/Radau_ODEsystem.py", line 981, in Rhs
    Error in importing compiled vector field and integrator.
    Did you compile the RHS C code?
        self._ensure_solver({'params': p, 't0': 0, 'tend': 1})
      File "anaconda/lib/python2.7/site-packages/PyDSTool/Generator/Radau_ODEsystem.py", line 1080, in _ensure_solver
        extraSpace=self.algparams['extraspace'])
      File "anaconda/lib/python2.7/site-packages/PyDSTool/Generator/Radau_ODEsystem.py", line 36, in __init__
        self._integMod = __import__(modname, globals())
      File "testpydstool/radau5_flight_vf.py", line 28, in <module>
        _radau5_flight_vf = swig_import_helper()
      File "ownCloud/model/testpydstool/radau5_flight_vf.py", line 24, in swig_import_helper
        _mod = imp.load_module('_radau5_flight_vf', fp, pathname, description)
    ImportError: dlopen(testpydstool/_radau5_flight_vf.so, 2): Symbol not found: _calzhip
      Referenced from: testpydstool/_radau5_flight_vf.so
      Expected in: dynamic lookup
    
    Process finished with exit code 1
    

    But I've tested some sample codes with Radau and Dopri, they worked fine. Does anyone know how to solve this problem?

    Thanks in advance.

     
  • Vladimir Zakharov

    What's in "radau5_temp/build.log" file?

    ImportError: dlopen(testpydstool/_radau5_flight_vf.so, 2): Symbol not found: _calzhip

    Is 'calzhip' defined somewhere?

     
    • Guoping Zhao

      Guoping Zhao - 2015-04-28

      Yes, 'calzhip' is a function defined in both events and sub-model args. There's no error if I change the integrator to vode.

      Here's "radau5_temp/build.log" file:

      running build_ext
      running build_src
      build_src
      building py_modules sources
      building library "radau5" sources
      building library "lapack_lite" sources
      building extension "_radau5_flight_vf" sources
      swig: /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/radau5_flight_vf.i
      swig -python -I/Users/guopingzhao/anaconda/lib/python2.7/site-packages/numpy/core/include -I/Users/guopingzhao/ownCloud/model/testpydstool -I/Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator -o /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/radau5_flight_vf_wrap.c -outdir  /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/radau5_flight_vf.i
      build_src: building npy-pkg config files
      customize UnixCCompiler
      customize UnixCCompiler using build_clib
      customize Gnu95FCompiler
      customize Gnu95FCompiler
      customize Gnu95FCompiler using build_clib
      customize UnixCCompiler
      customize UnixCCompiler using build_ext
      customize Gnu95FCompiler
      customize Gnu95FCompiler
      customize Gnu95FCompiler using build_ext
      building '_radau5_flight_vf' extension
      compiling C sources
      C compiler: gcc -fno-strict-aliasing -I/Users/guopingzhao/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
      
      compile options: '-I/Users/guopingzhao/anaconda/lib/python2.7/site-packages/numpy/core/include -I/Users/guopingzhao/ownCloud/model/testpydstool -I/Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator -I/Users/guopingzhao/anaconda/lib/python2.7/site-packages/numpy/core/include -I/Users/guopingzhao/anaconda/include/python2.7 -c'
      extra options: '-w -Wno-return-type -Wall -D__RADAU__'
      gcc: /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/radau5_flight_vf_wrap.c
      gcc: /Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/memory.c
      gcc: /Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/interface.c
      gcc: /Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/radau5mod.c
      gcc: /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/flight_vf.c
      gcc: /Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/eventFinding.c
      gcc: /Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/integration.c
      /usr/local/bin/gfortran -Wall -m64 -Wall -undefined dynamic_lookup -bundle /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/flight_vf.o /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/radau5mod.o /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/integration.o /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/interface.o /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/eventFinding.o /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/Users/guopingzhao/anaconda/lib/python2.7/site-packages/PyDSTool/integrator/memory.o /Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/Users/guopingzhao/ownCloud/model/testpydstool/radau5_temp/radau5_flight_vf_wrap.o -L/usr/local/Cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.2.0/4.9.1 -L/Users/guopingzhao/anaconda/lib -Lbuild/temp.macosx-10.5-x86_64-2.7 -lradau5 -llapack_lite -lgfortran -o _radau5_flight_vf.so -w
      
       

      Last edit: Guoping Zhao 2015-04-28
  • Vladimir Zakharov

    Is there the definition of 'calzhip' function in generated VF file "radau5_temp/flight_vf.c"?

    Show us, how you define 'calzhip' in your code.

     
    • Guoping Zhao

      Guoping Zhao - 2015-04-28

      Hmm, 'calzhip' function is not generated in the file "radau5_temp/flight_vf.c".

      I think here's the part which is related to 'calzhip' and 'flight_vf':

      touchdown_args = {'eventtol': abseps / 10,
                            'eventdelay': abseps * 10,
                            'eventinterval': abseps * 10,
                            'active': True,
                            'term': True,
                            'precise': True,
                            'name': 'touchdown'}
      touchdown_ev = Events.makeZeroCrossEvent('calzhip(z,thetaH) - l0*sin(gam)', -1,
                                                   touchdown_args, ['z', 'thetaH'], ['l0', 'd', 'gam'],
                                                   fnspecs={'calzhip': (['z', 'thH'], 'z-d*sin(thH)')},
                                                   targetlang=targetlang)
      flight_args = getFlightArgs(algparams, touchdown_ev, pars, abseps)
      
      def getFlightArgs(algparams, touchdown_ev, pars, abseps):
          return {'pars': pars,
                  'varspecs': {'y': "ydot",
                               'ydot': "0",
                               'z': "zdot",
                               'zdot': "-g",
                               'thetaH': "thetaHdot",
                               'thetaHdot': "0",
                               'incontact': "0"},
                  'xdomain': {'y': [0,Inf], 'z': [0,Inf], 'thetaH': [-pi,pi], 'incontact': 0},
                  'pdomain': {'gam': [pi/2,pi]},
                  'ics': {'incontact': 0},
                  'xtype': {'incontact': int},
                  'algparams': algparams,
                  'events': [touchdown_ev],
                  'abseps': abseps,
                  'name': 'flight'}
      
       
      • Guoping Zhao

        Guoping Zhao - 2015-04-28

        There'll be no error if I remove the function 'calzhip' in event definition. That is:

        touchdown_ev = Events.makeZeroCrossEvent('z-d*sin(thetaH) - l0*sin(gam)', -1,
                                                     touchdown_args, ['z', 'thetaH'], ['l0', 'd', 'gam'],
                                                     targetlang=targetlang)
        

        But why?

         
  • Vladimir Zakharov

    Possibly bug, but not sure about support for using functions in C events.
    Maybe Robert will be able to shed some light on this.

     
    • Guoping Zhao

      Guoping Zhao - 2015-04-28

      It should support. I saw it in the sample script SLIP_2D.py. My other codes also have functions in C event and work fine.

      Maybe it's a bug.

      Thanks a lot for your help.

       

      Last edit: Guoping Zhao 2015-04-28
      • Vladimir Zakharov

        Then duplicate 'fnspecs' key with 'calzhip' definition in dict, which function 'getFlightArgs' returns. Like it's done for 'zeta' function in SLIP_2D.py.

         
        • Guoping Zhao

          Guoping Zhao - 2015-04-28

          Yes, you're right. I duplicate that and no errors anymore.

          Thanks.

           
  • Rob Clewley

    Rob Clewley - 2015-04-28

    It looks like getFlightArgs does not return a dict entry for fnspecs that also contains the definition of calzhip. The fnspecs for the event definition is just to help out the event code in knowing what the constituent parts of the definition mean: they don't actually define anything.

     
    • Guoping Zhao

      Guoping Zhao - 2015-04-28

      Ah, I see. Thank you.

      Do you know where I can find this kind of information? I didn't find it on your tutorial webpages: http://www.ni.gsu.edu/~rclewley/PyDSTool/Tutorial.html

       
      • Rob Clewley

        Rob Clewley - 2015-04-28

        The User Documentation points to several other pages to read, which cover this. The FuncSpec page, Sections 3 and 5, describes the dictionary for defining auxiliary functions. I have added some more explicit text to reinforce the idea that the fnspecs entry in the Generator creation arguments must be added for this to work.

        The description of the fnspecs dictionary for events is given
        here, Section 2.

        The second tutorial and other examples and tutorials show how aux functions are declared.

         
        • Guoping Zhao

          Guoping Zhao - 2015-04-29

          Thanks. It's very helpful.

           
  • Rob Clewley

    Rob Clewley - 2015-04-28

    I'm not sure how it's possible for that code to run with Vode. It would be helpful if you just privately emailed me your whole script.

     
    • Guoping Zhao

      Guoping Zhao - 2015-04-28

      OK, email sent. Thanks.

       

Log in to post a comment.