├── .gitignore ├── README.md ├── WormESP32 ├── Readme.txt ├── hcsr04.py ├── hcsr04_test.py ├── segment_angles.txt ├── servo_reset.py ├── servo_test.py ├── vl53l0x.py ├── vl53l0x_test.py ├── worm_run_segment_angles.py ├── worm_run_segment_angles_laser.py ├── worm_run_segment_angles_sim.py └── worm_run_segment_angles_sonic.py ├── WormHost ├── Celegans_robot.ipynb ├── Readme.txt ├── _wormpy.pyd ├── get_sensors.py ├── muscles.json ├── put_muscles.py ├── put_muscles.sh ├── run_notebook.sh ├── sensors.json ├── worm_run.py ├── wormpy.py └── wormpy.pyc ├── WormRPi ├── Raspberry-Pi-GPIO-Layout-Model-B-Plus-rotated.png ├── Readme.txt ├── Servo.py ├── amplitudes.py ├── arecord.sh ├── asoundrc.txt ├── flask_app.py ├── food_listener.py ├── muscles.json ├── segment_angles.txt ├── sensors.json ├── servo_reset.py ├── servo_test.py ├── sonar.py ├── test_audio.py ├── worm_gen_segment_angles.py ├── worm_run.py ├── worm_run_angles.py ├── worm_run_segment_angles.py └── wpa_supplicant.conf ├── WormSim ├── MatlabSupport │ ├── WormView.m │ ├── extractAndPlotEigenCurves.m │ └── familyEigenVectorsFromAngles.m ├── Model │ ├── Makefile │ ├── Readme.txt │ ├── gettime.cpp │ ├── gettime.h │ ├── main.cpp │ ├── worm.cc │ ├── worm.vcxproj │ ├── worm.vcxproj.filters │ ├── worm_run.py │ ├── worm_test.py │ ├── wormpy.i │ ├── wormpy.vcxproj │ ├── wormpy.vcxproj.filters │ ├── wormpy_wrap.cxx │ ├── wormsim.cpp │ ├── wormsim.h │ └── wormsim.sln ├── README.md └── sundials-2.3.0 │ ├── INSTALL_NOTES │ ├── LICENSE │ ├── Makefile.in │ ├── README │ ├── acinclude.m4 │ ├── config.h │ ├── config.hin │ ├── config.log │ ├── config │ ├── config.guess │ ├── config.sub │ ├── cust_general.m4 │ ├── fortran_update.in │ ├── install-sh │ ├── ltmain.sh │ ├── mkinstalldirs │ ├── mod_c.m4 │ ├── mod_fortran.m4 │ └── sundials-config.in │ ├── configure │ ├── configure.ac │ ├── doc │ ├── cvode │ │ ├── cv_examples.pdf │ │ └── cv_guide.pdf │ ├── cvodes │ │ ├── cvs_examples.pdf │ │ └── cvs_guide.pdf │ ├── ida │ │ ├── ida_examples.pdf │ │ └── ida_guide.pdf │ └── kinsol │ │ ├── kin_examples.pdf │ │ └── kin_guide.pdf │ ├── examples │ ├── cvode │ │ ├── fcmix_parallel │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── fcvkryx_bbd_p.f │ │ │ ├── fcvkryx_bbd_p.out │ │ │ ├── fcvkryx_p.f │ │ │ ├── fcvkryx_p.out │ │ │ ├── fcvnonx_p.f │ │ │ └── fcvnonx_p.out │ │ ├── fcmix_serial │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── fcvbanx.f │ │ │ ├── fcvbanx.out │ │ │ ├── fcvdenx.f │ │ │ ├── fcvdenx.out │ │ │ ├── fcvkryx.f │ │ │ ├── fcvkryx.out │ │ │ ├── fcvkryx_bp.f │ │ │ └── fcvkryx_bp.out │ │ ├── parallel │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── cvkryx_bbd_p.c │ │ │ ├── cvkryx_bbd_p.out │ │ │ ├── cvkryx_p.c │ │ │ ├── cvkryx_p.out │ │ │ ├── cvnonx_p.c │ │ │ └── cvnonx_p.out │ │ └── serial │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── cvbanx.c │ │ │ ├── cvbanx.out │ │ │ ├── cvdenx.c │ │ │ ├── cvdenx.out │ │ │ ├── cvdenx_uw.c │ │ │ ├── cvdenx_uw.out │ │ │ ├── cvdirectdem.c │ │ │ ├── cvdirectdem.out │ │ │ ├── cvkrydem_lin.c │ │ │ ├── cvkrydem_lin.out │ │ │ ├── cvkrydem_pre.c │ │ │ ├── cvkrydem_pre.out │ │ │ ├── cvkryx.c │ │ │ ├── cvkryx.out │ │ │ ├── cvkryx_bp.c │ │ │ └── cvkryx_bp.out │ ├── cvodes │ │ ├── parallel │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── cvsadjkryx_p.c │ │ │ ├── cvsadjkryx_p.out │ │ │ ├── cvsadjnonx_p.c │ │ │ ├── cvsadjnonx_p.out │ │ │ ├── cvsfwdkryx_p.c │ │ │ ├── cvsfwdkryx_p.out1 │ │ │ ├── cvsfwdkryx_p.out2 │ │ │ ├── cvsfwdnonx_p.c │ │ │ ├── cvsfwdnonx_p.out1 │ │ │ ├── cvsfwdnonx_p.out2 │ │ │ ├── cvskryx_bbd_p.c │ │ │ ├── cvskryx_bbd_p.out │ │ │ ├── cvskryx_p.c │ │ │ ├── cvskryx_p.out │ │ │ ├── cvsnonx_p.c │ │ │ └── cvsnonx_p.out │ │ └── serial │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── cvsadjbanx.c │ │ │ ├── cvsadjbanx.out │ │ │ ├── cvsadjdenx.c │ │ │ ├── cvsadjdenx.out │ │ │ ├── cvsadjkryx_int.c │ │ │ ├── cvsadjkryx_int.out │ │ │ ├── cvsadjkryx_pnt.c │ │ │ ├── cvsadjkryx_pnt.out │ │ │ ├── cvsbanx.c │ │ │ ├── cvsbanx.out │ │ │ ├── cvsdenx.c │ │ │ ├── cvsdenx.out │ │ │ ├── cvsdenx_uw.c │ │ │ ├── cvsdenx_uw.out │ │ │ ├── cvsdirectdem.c │ │ │ ├── cvsdirectdem.out │ │ │ ├── cvsfwddenx.c │ │ │ ├── cvsfwddenx.out1 │ │ │ ├── cvsfwddenx.out2 │ │ │ ├── cvsfwdkryx.c │ │ │ ├── cvsfwdkryx.out1 │ │ │ ├── cvsfwdkryx.out2 │ │ │ ├── cvsfwdnonx.c │ │ │ ├── cvsfwdnonx.out1 │ │ │ ├── cvsfwdnonx.out2 │ │ │ ├── cvskrydem_lin.c │ │ │ ├── cvskrydem_lin.out │ │ │ ├── cvskrydem_pre.c │ │ │ ├── cvskrydem_pre.out │ │ │ ├── cvskryx.c │ │ │ ├── cvskryx.out │ │ │ ├── cvskryx_bp.c │ │ │ └── cvskryx_bp.out │ ├── ida │ │ ├── fcmix_parallel │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── fidakryx_bbd_p.f │ │ │ └── fidakryx_bbd_p.out │ │ ├── fcmix_serial │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── fidadenx.f │ │ │ └── fidadenx.out │ │ ├── parallel │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── idakryx1_bbd_p.c │ │ │ ├── idakryx1_bbd_p.out │ │ │ ├── idakryx1_p.c │ │ │ ├── idakryx1_p.out │ │ │ ├── idakryx2_bbd_p.c │ │ │ ├── idakryx2_bbd_p.out │ │ │ ├── idakryx2_p.c │ │ │ └── idakryx2_p.out │ │ └── serial │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── idabanx1.c │ │ │ ├── idabanx1.out │ │ │ ├── idabanx2.c │ │ │ ├── idabanx2.out │ │ │ ├── idadenx.c │ │ │ ├── idadenx.out │ │ │ ├── idakrydem_lin.c │ │ │ ├── idakrydem_lin.out │ │ │ ├── idakryx.c │ │ │ └── idakryx.out │ └── kinsol │ │ ├── fcmix_parallel │ │ ├── Makefile.in │ │ ├── README │ │ ├── fkinkryx_p.f │ │ └── fkinkryx_p.out │ │ ├── fcmix_serial │ │ ├── Makefile.in │ │ ├── README │ │ ├── fkinkryx.f │ │ └── fkinkryx.out │ │ ├── parallel │ │ ├── Makefile.in │ │ ├── README │ │ ├── kinkryx_bbd_p.c │ │ ├── kinkryx_bbd_p.out │ │ ├── kinkryx_p.c │ │ └── kinkryx_p.out │ │ └── serial │ │ ├── Makefile.in │ │ ├── README │ │ ├── kinbanx.c │ │ ├── kinbanx.out │ │ ├── kindenx1.c │ │ ├── kindenx1.out │ │ ├── kindenx2.c │ │ ├── kindenx2.out │ │ ├── kinkrydem_lin.c │ │ ├── kinkrydem_lin.out │ │ ├── kinkryx.c │ │ └── kinkryx.out │ ├── include │ ├── cvode │ │ ├── cvode.h │ │ ├── cvode_band.h │ │ ├── cvode_bandpre.h │ │ ├── cvode_bbdpre.h │ │ ├── cvode_dense.h │ │ ├── cvode_diag.h │ │ ├── cvode_spbcgs.h │ │ ├── cvode_spgmr.h │ │ ├── cvode_spils.h │ │ └── cvode_sptfqmr.h │ ├── cvodes │ │ ├── cvodes.h │ │ ├── cvodes_band.h │ │ ├── cvodes_bandpre.h │ │ ├── cvodes_bbdpre.h │ │ ├── cvodes_dense.h │ │ ├── cvodes_diag.h │ │ ├── cvodes_spbcgs.h │ │ ├── cvodes_spgmr.h │ │ ├── cvodes_spils.h │ │ └── cvodes_sptfqmr.h │ ├── ida │ │ ├── ida.h │ │ ├── ida_band.h │ │ ├── ida_bbdpre.h │ │ ├── ida_dense.h │ │ ├── ida_spbcgs.h │ │ ├── ida_spgmr.h │ │ ├── ida_spils.h │ │ └── ida_sptfqmr.h │ ├── kinsol │ │ ├── kinsol.h │ │ ├── kinsol_band.h │ │ ├── kinsol_bbdpre.h │ │ ├── kinsol_dense.h │ │ ├── kinsol_spbcgs.h │ │ ├── kinsol_spgmr.h │ │ ├── kinsol_spils.h │ │ └── kinsol_sptfqmr.h │ ├── nvector │ │ ├── nvector_parallel.h │ │ └── nvector_serial.h │ └── sundials │ │ ├── sundials_band.h │ │ ├── sundials_dense.h │ │ ├── sundials_fnvector.h │ │ ├── sundials_iterative.h │ │ ├── sundials_math.h │ │ ├── sundials_nvector.h │ │ ├── sundials_smalldense.h │ │ ├── sundials_spbcgs.h │ │ ├── sundials_spgmr.h │ │ ├── sundials_sptfqmr.h │ │ └── sundials_types.h │ ├── src │ ├── cvode │ │ ├── LICENSE │ │ ├── Makefile.in │ │ ├── README │ │ ├── cvode.c │ │ ├── cvode_band.c │ │ ├── cvode_band_impl.h │ │ ├── cvode_bandpre.c │ │ ├── cvode_bandpre_impl.h │ │ ├── cvode_bbdpre.c │ │ ├── cvode_bbdpre_impl.h │ │ ├── cvode_dense.c │ │ ├── cvode_dense_impl.h │ │ ├── cvode_diag.c │ │ ├── cvode_diag_impl.h │ │ ├── cvode_impl.h │ │ ├── cvode_io.c │ │ ├── cvode_spbcgs.c │ │ ├── cvode_spgmr.c │ │ ├── cvode_spils.c │ │ ├── cvode_spils_impl.h │ │ ├── cvode_sptfqmr.c │ │ └── fcmix │ │ │ ├── Makefile.in │ │ │ ├── fcvband.c │ │ │ ├── fcvbbd.c │ │ │ ├── fcvbbd.h │ │ │ ├── fcvbp.c │ │ │ ├── fcvbp.h │ │ │ ├── fcvdense.c │ │ │ ├── fcvewt.c │ │ │ ├── fcvjtimes.c │ │ │ ├── fcvode.c │ │ │ ├── fcvode.h │ │ │ ├── fcvpreco.c │ │ │ ├── fcvroot.c │ │ │ └── fcvroot.h │ ├── cvodes │ │ ├── LICENSE │ │ ├── Makefile.in │ │ ├── README │ │ ├── cvodea.c │ │ ├── cvodea_io.c │ │ ├── cvodes.c │ │ ├── cvodes_band.c │ │ ├── cvodes_band_impl.h │ │ ├── cvodes_bandpre.c │ │ ├── cvodes_bandpre_impl.h │ │ ├── cvodes_bbdpre.c │ │ ├── cvodes_bbdpre_impl.h │ │ ├── cvodes_dense.c │ │ ├── cvodes_dense_impl.h │ │ ├── cvodes_diag.c │ │ ├── cvodes_diag_impl.h │ │ ├── cvodes_impl.h │ │ ├── cvodes_io.c │ │ ├── cvodes_spbcgs.c │ │ ├── cvodes_spgmr.c │ │ ├── cvodes_spils.c │ │ ├── cvodes_spils_impl.h │ │ └── cvodes_sptfqmr.c │ ├── ida │ │ ├── LICENSE │ │ ├── Makefile.in │ │ ├── README │ │ ├── fcmix │ │ │ ├── Makefile.in │ │ │ ├── fida.c │ │ │ ├── fida.h │ │ │ ├── fidaband.c │ │ │ ├── fidabbd.c │ │ │ ├── fidabbd.h │ │ │ ├── fidadense.c │ │ │ ├── fidaewt.c │ │ │ ├── fidajtimes.c │ │ │ ├── fidapreco.c │ │ │ ├── fidaroot.c │ │ │ └── fidaroot.h │ │ ├── ida.c │ │ ├── ida_band.c │ │ ├── ida_band_impl.h │ │ ├── ida_bbdpre.c │ │ ├── ida_bbdpre_impl.h │ │ ├── ida_dense.c │ │ ├── ida_dense_impl.h │ │ ├── ida_ic.c │ │ ├── ida_impl.h │ │ ├── ida_io.c │ │ ├── ida_spbcgs.c │ │ ├── ida_spgmr.c │ │ ├── ida_spils.c │ │ ├── ida_spils_impl.h │ │ └── ida_sptfqmr.c │ ├── kinsol │ │ ├── LICENSE │ │ ├── Makefile.in │ │ ├── README │ │ ├── fcmix │ │ │ ├── Makefile.in │ │ │ ├── fkinband.c │ │ │ ├── fkinbbd.c │ │ │ ├── fkinbbd.h │ │ │ ├── fkindense.c │ │ │ ├── fkinjtimes.c │ │ │ ├── fkinpreco.c │ │ │ ├── fkinsol.c │ │ │ └── fkinsol.h │ │ ├── kinsol.c │ │ ├── kinsol_band.c │ │ ├── kinsol_band_impl.h │ │ ├── kinsol_bbdpre.c │ │ ├── kinsol_bbdpre_impl.h │ │ ├── kinsol_dense.c │ │ ├── kinsol_dense_impl.h │ │ ├── kinsol_impl.h │ │ ├── kinsol_io.c │ │ ├── kinsol_spbcgs.c │ │ ├── kinsol_spgmr.c │ │ ├── kinsol_spils.c │ │ ├── kinsol_spils_impl.h │ │ └── kinsol_sptfqmr.c │ ├── nvec_par │ │ ├── Makefile.in │ │ ├── README │ │ ├── fnvector_parallel.c │ │ ├── fnvector_parallel.h │ │ └── nvector_parallel.c │ ├── nvec_ser │ │ ├── Makefile.in │ │ ├── README │ │ ├── fnvector_serial.c │ │ ├── fnvector_serial.h │ │ └── nvector_serial.c │ └── sundials │ │ ├── Makefile.in │ │ ├── README │ │ ├── sundials_band.c │ │ ├── sundials_config.h │ │ ├── sundials_config.in │ │ ├── sundials_dense.c │ │ ├── sundials_iterative.c │ │ ├── sundials_math.c │ │ ├── sundials_nvector.c │ │ ├── sundials_smalldense.c │ │ ├── sundials_spbcgs.c │ │ ├── sundials_spgmr.c │ │ └── sundials_sptfqmr.c │ └── sundialsTB │ ├── Contents.m │ ├── LICENSE │ ├── Makefile.in │ ├── README │ ├── cvodes │ ├── CVBandJacFn.m │ ├── CVDenseJacFn.m │ ├── CVGcommFn.m │ ├── CVGlocalFn.m │ ├── CVJacTimesVecFn.m │ ├── CVMonitorFn.m │ ├── CVPrecSetupFn.m │ ├── CVPrecSolveFn.m │ ├── CVQuadRhsFn.m │ ├── CVRhsFn.m │ ├── CVRootFn.m │ ├── CVSensRhsFn.m │ ├── CVadjMalloc.m │ ├── CVode.m │ ├── CVodeB.m │ ├── CVodeFree.m │ ├── CVodeGet.m │ ├── CVodeGetStats.m │ ├── CVodeGetStatsB.m │ ├── CVodeMalloc.m │ ├── CVodeMallocB.m │ ├── CVodeMonitor.m │ ├── CVodeReInit.m │ ├── CVodeReInitB.m │ ├── CVodeSensMalloc.m │ ├── CVodeSensReInit.m │ ├── CVodeSensToggleOff.m │ ├── CVodeSetFSAOptions.m │ ├── CVodeSetOptions.m │ ├── Contents.m │ ├── cvm │ │ ├── Contents.m │ │ ├── cvm_bjac.m │ │ ├── cvm_djac.m │ │ ├── cvm_gcom.m │ │ ├── cvm_gloc.m │ │ ├── cvm_jtv.m │ │ ├── cvm_monitor.m │ │ ├── cvm_pset.m │ │ ├── cvm_psol.m │ │ ├── cvm_rhs.m │ │ ├── cvm_rhsQ.m │ │ ├── cvm_rhsS.m │ │ ├── cvm_root.m │ │ └── src │ │ │ ├── Makefile.in │ │ │ ├── cvm.c │ │ │ ├── cvm.h │ │ │ ├── cvmOpts.c │ │ │ ├── cvmWrap.c │ │ │ └── setup.m.in │ ├── examples_par │ │ ├── pvfnx.m │ │ ├── pvfnx_f.m │ │ ├── pvkx.m │ │ ├── pvkx_f.m │ │ ├── pvkx_fl.m │ │ ├── pvnx.m │ │ └── pvnx_f.m │ └── examples_ser │ │ ├── cvadx.m │ │ ├── cvbx.m │ │ ├── cvbx_J.m │ │ ├── cvbx_f.m │ │ ├── cvbx_q.m │ │ ├── cvdiscx.m │ │ ├── cvdx.m │ │ ├── cvdx_J.m │ │ ├── cvdx_JB.m │ │ ├── cvdx_f.m │ │ ├── cvdx_fB.m │ │ ├── cvdx_fS.m │ │ ├── cvdx_g.m │ │ ├── cvdx_q.m │ │ ├── cvdx_qB.m │ │ ├── cvfdx.m │ │ ├── cvkx.m │ │ ├── cvkx_f.m │ │ ├── cvkx_pset.m │ │ ├── cvkx_psol.m │ │ ├── cvkxb.m │ │ ├── pleiades.m │ │ ├── pleiades_J.m │ │ ├── pleiades_f.m │ │ ├── vdp.m │ │ ├── vdp_J.m │ │ └── vdp_f.m │ ├── doc │ └── sundialsTB.pdf │ ├── idas │ ├── Contents.m │ ├── IDABandJacFn.m │ ├── IDACalcIC.m │ ├── IDACalcICB.m │ ├── IDADenseJacFn.m │ ├── IDAFree.m │ ├── IDAGcommFn.m │ ├── IDAGet.m │ ├── IDAGetStats.m │ ├── IDAGetStatsB.m │ ├── IDAGlocalFn.m │ ├── IDAJacTimesVecFn.m │ ├── IDAMalloc.m │ ├── IDAMallocB.m │ ├── IDAMonitor.m │ ├── IDAMonitorFn.m │ ├── IDAPrecSetupFn.m │ ├── IDAPrecSolveFn.m │ ├── IDAQuadRhsFn.m │ ├── IDAResFn.m │ ├── IDARootFn.m │ ├── IDASensMalloc.m │ ├── IDASensResFn.m │ ├── IDASetFSAOptions.m │ ├── IDASetOptions.m │ ├── IDASolve.m │ ├── IDASolveB.m │ ├── IDAadjMalloc.m │ ├── examples_ser │ │ ├── idabanx.m │ │ ├── idabanx_f.m │ │ ├── idabanx_ic.m │ │ ├── idadenx.m │ │ ├── idadenx_J.m │ │ ├── idadenx_f.m │ │ ├── idadenx_g.m │ │ ├── pend.m │ │ └── pendGGL.m │ └── idm │ │ ├── Contents.m │ │ ├── idm_bjac.m │ │ ├── idm_djac.m │ │ ├── idm_gcom.m │ │ ├── idm_gloc.m │ │ ├── idm_jtv.m │ │ ├── idm_monitor.m │ │ ├── idm_pset.m │ │ ├── idm_psol.m │ │ ├── idm_res.m │ │ ├── idm_resS.m │ │ ├── idm_rhsQ.m │ │ ├── idm_root.m │ │ └── src │ │ ├── Makefile.in │ │ ├── idm.c │ │ ├── idm.h │ │ ├── idmOpts.c │ │ ├── idmWrap.c │ │ └── setup.m.in │ ├── install_STB.m │ ├── kinsol │ ├── Contents.m │ ├── KINBandJacFn.m │ ├── KINDenseJacFn.m │ ├── KINFree.m │ ├── KINGcommFn.m │ ├── KINGetStats.m │ ├── KINGlocalFn.m │ ├── KINJacTimesVecFn.m │ ├── KINMalloc.m │ ├── KINPrecSetupFn.m │ ├── KINPrecSolveFn.m │ ├── KINSetOptions.m │ ├── KINSol.m │ ├── KINSysFn.m │ ├── examples_par │ │ ├── kindiagp.m │ │ ├── kindiagp_pset.m │ │ ├── kindiagp_psol.m │ │ └── kindiagp_sys.m │ ├── examples_ser │ │ ├── kindiag.m │ │ ├── kindiag_pset.m │ │ ├── kindiag_psol.m │ │ ├── kindiag_sys.m │ │ ├── kindx.m │ │ └── kindx_sys.m │ └── kim │ │ ├── Contents.m │ │ ├── kim_bjac.m │ │ ├── kim_djac.m │ │ ├── kim_gcom.m │ │ ├── kim_gloc.m │ │ ├── kim_info.m │ │ ├── kim_jtv.m │ │ ├── kim_pset.m │ │ ├── kim_psol.m │ │ ├── kim_sys.m │ │ └── src │ │ ├── Makefile.in │ │ ├── kim.c │ │ ├── kim.h │ │ ├── kimOpts.c │ │ ├── kimWrap.c │ │ └── setup.m.in │ ├── nvector │ ├── Contents.m │ ├── N_VDotProd.m │ ├── N_VL1Norm.m │ ├── N_VMax.m │ ├── N_VMaxNorm.m │ ├── N_VMin.m │ ├── N_VWL2Norm.m │ ├── N_VWrmsNorm.m │ └── src │ │ ├── nvm.h │ │ ├── nvm_ops.c │ │ ├── nvm_parallel.c │ │ └── nvm_serial.c │ ├── putils │ ├── Contents.m │ ├── mpirun.m │ ├── mpiruns.m │ └── mpistart.m │ └── startup_STB.in ├── assembly ├── Robot_Worm_ESP32_assembly.docx ├── Robot_Worm_RaspberryPi_assembly.docx ├── Worm_Body.stl ├── Worm_Head.stl ├── Worm_RPi_PWM_Stand.stl ├── Worm_Stand.stl └── Worm_battery_stand.stl └── docs ├── C_elegans_robot.docx └── _config.yml /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.obj 3 | *.log 4 | *.tlog 5 | *.pdb 6 | *.ipdb 7 | *.idb 8 | .vs/ 9 | WormSim/Model/**/*.user 10 | WormSim/Model/**/Release 11 | WormSim/Model/**/Debug 12 | .ipynb_checkpoints 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # robots 2 | C. elegans robots. 3 | 4 | The goal of this project is twofold: 5 | 1. To build a robot that simulates the neuromuscular function of a C. elegans nematode worm. 6 | 2. To specify a kit of parts and instructions that will allow a student to also build the robot. 7 | 8 | The robot is controlled by a Raspberry Pi/ESP32 processor that contains a recorded simulation of the worm's 9 | neuromuscular system (see references). The robot's body is a sequence of segments that mutually exert simulated muscle 10 | contractions impemented by servos. 11 | 12 | Folders: 13 | 1. WormHost: PC code to communicate with the onboard Raspberry Pi. 14 | 2. WormRPi: Raspberry Pi onboard code. 15 | 3. WormESP32: ESP32 onboard code. 16 | 4. WormSim: C. elegans neuromuscular simulator. 17 | 5. assembly: parts list, 3D printing .stl shape files, and assembly instructions. 18 | 6. docs: robot description. 19 | 20 | References: 21 | Boyle, Berri and Cohen, "Gait modulation in C. elegans: an integrated neuromechanical model", Front. Comput. Neurosci., 2012. 22 | Eduardo J. Izquierdo and Randall D. Beer, "An Integrated Neuromechanical Model of Steering in C. elegans", ECAL15 -------------------------------------------------------------------------------- /WormESP32/Readme.txt: -------------------------------------------------------------------------------- 1 | C elegans worm robot with ESP32. 2 | A distance sensor simulates food foraging by locating and moving toward the nearest object. 3 | 4 | Power up the ESP32 and connect to its network: Robot_Worm 5 | ESP32 IP address should be 192.169.4.1 6 | 7 | Transfer python and segment_angles.txt to ESP32 using ftp. 8 | 9 | FTP: 10 | For linux: 11 | In ftp connection, issue "passive" command to avoid attempt to open a server-to-client data connection. 12 | This connection will be refused. 13 | Cygwin: 14 | Get ftp by installing inetutils package (also gets telnet). 15 | FileZilla instructions: 16 | https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/ftpserver 17 | 18 | Login with telnet: 19 | telnet 192.168.4.1 20 | login=micro, password=python 21 | 22 | Run scripts: 23 | 1. To straighten robot: 24 | exec(open("servo_reset.py").read()) 25 | 2. To test servos: 26 | exec(open("servo_test.py").read()) 27 | 3. Run no food sensor: 28 | exec(open("worm_run_segment_angles.py").read()) 29 | 4. Run with laser distance food sensor: 30 | exec(open("worm_run_segment_angles_laser.py").read()) 31 | 5. Run with ultrasonic distance food sensor: 32 | exec(open("worm_run_segment_angles_sonic.py").read()) 33 | 34 | The maximim number of steps can be limited by creating a file named "max_steps.txt" containing the value. 35 | 36 | Note: power cycle board if you encounter python errors after repeated runs. 37 | 38 | -------------------------------------------------------------------------------- /WormESP32/hcsr04.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormESP32/hcsr04.py -------------------------------------------------------------------------------- /WormESP32/hcsr04_test.py: -------------------------------------------------------------------------------- 1 | import time 2 | import hcsr04 3 | 4 | #create an instance of the HCSR04 distance sensor. 5 | # trigger=32, echo=33 6 | distance_sensor = hcsr04.HCSR04(32, 33) 7 | 8 | while True: 9 | print(distance_sensor.distance_cm()) 10 | time.sleep(3) 11 | -------------------------------------------------------------------------------- /WormESP32/servo_reset.py: -------------------------------------------------------------------------------- 1 | from machine import PWM, I2C, Pin 2 | from math import pi, radians 3 | from BOTS import * #import all custom code for the board 4 | 5 | #create an instance of the I2C bus 6 | I2C_servo_bus = I2C(0, speed=100000, sda=27, scl=26) 7 | 8 | #create instance of the servo driver 9 | robot = Servo(I2C_servo_bus) 10 | 11 | #set the servos to position 0 12 | robot.set_servo (0, 0) 13 | robot.set_servo (0, 1) 14 | robot.set_servo (0, 2) 15 | robot.set_servo (0, 3) 16 | robot.set_servo (0, 4) 17 | robot.set_servo (0, 5) 18 | robot.set_servo (0, 6) 19 | robot.set_servo (0, 7) 20 | 21 | I2C_servo_bus.deinit() 22 | -------------------------------------------------------------------------------- /WormESP32/servo_test.py: -------------------------------------------------------------------------------- 1 | from machine import PWM, I2C, Pin 2 | from math import pi, radians 3 | from BOTS import * #import all custom code for the board 4 | 5 | #create an instance of the I2C bus 6 | I2C_bus = I2C(0, sda=27, scl=26) 7 | 8 | #create instance of the servo driver 9 | robot = Servo(I2C_bus) 10 | 11 | #set servos to test positions. 12 | robot.set_servo (radians(45), 0) 13 | robot.set_servo (radians(-45), 1) 14 | robot.set_servo (radians(45), 2) 15 | robot.set_servo (radians(-45), 3) 16 | robot.set_servo (radians(45), 4) 17 | robot.set_servo (radians(-45), 5) 18 | robot.set_servo (radians(45), 6) 19 | robot.set_servo (radians(-45), 7) 20 | 21 | I2C_bus.deinit() 22 | -------------------------------------------------------------------------------- /WormESP32/vl53l0x_test.py: -------------------------------------------------------------------------------- 1 | import time, display, network 2 | from machine import PWM, I2C, Pin 3 | from math import pi, radians 4 | from microWebSrv import MicroWebSrv 5 | from BOTS import * #import all custom code for the board 6 | import vl53l0x 7 | 8 | #create an instance of the I2C bus 9 | I2C_sensor_bus = I2C(1, speed=400000, sda=32, scl=33) 10 | 11 | #create an instance of the VL53L0X distance sensor. 12 | distance_sensor = vl53l0x.VL53L0X(I2C_sensor_bus) 13 | 14 | while True: 15 | print(distance_sensor.read()) 16 | time.sleep(3) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /WormHost/Readme.txt: -------------------------------------------------------------------------------- 1 | C elegans worm robot host code. 2 | 3 | Standalone simulation: python worm_run.py 4 | 5 | Interface with RPi: 6 | 1. Set up RPi (see WormRPi) 7 | 2. Run get_sensors.py to get sensor values from robot. 8 | 3. Run put_muscles.py to send muscle activations to robot. 9 | 10 | Run simulator with RPi: jupyter notebook, then open Celegans_robot.ipynb 11 | -------------------------------------------------------------------------------- /WormHost/_wormpy.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormHost/_wormpy.pyd -------------------------------------------------------------------------------- /WormHost/get_sensors.py: -------------------------------------------------------------------------------- 1 | import requests, json 2 | 3 | url = "http://192.168.0.25:5000/robot/sensors" 4 | r = requests.get(url) 5 | print r.json() 6 | 7 | -------------------------------------------------------------------------------- /WormHost/muscles.json: -------------------------------------------------------------------------------- 1 | { 2 | "muscles": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] 3 | } 4 | -------------------------------------------------------------------------------- /WormHost/put_muscles.py: -------------------------------------------------------------------------------- 1 | import requests, json 2 | 3 | url = "http://192.168.0.25:5000/robot/muscles" 4 | payload = json.load(open("muscles.json")) 5 | headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8'} 6 | r = requests.post(url, data=json.dumps(payload), headers=headers) 7 | print r.json() 8 | 9 | -------------------------------------------------------------------------------- /WormHost/put_muscles.sh: -------------------------------------------------------------------------------- 1 | curl -i -H "Content-Type: application/json" -X POST -d '{"muscles":[1,2,3,4,5,6,7,8,9,10,11,12]}' "http://192.168.0.25:5000/robot/muscles" 2 | -------------------------------------------------------------------------------- /WormHost/run_notebook.sh: -------------------------------------------------------------------------------- 1 | ipython notebook Celegans_robot.ipynb 2 | -------------------------------------------------------------------------------- /WormHost/sensors.json: -------------------------------------------------------------------------------- 1 | { 2 | "asel": 1.0, 3 | "aser": 0.0 4 | } 5 | -------------------------------------------------------------------------------- /WormHost/worm_run.py: -------------------------------------------------------------------------------- 1 | # Worm simulation. 2 | import wormpy 3 | wormpy.init() 4 | wormpy.step() 5 | angles = [] 6 | activations = [] 7 | for segment in range(12) : 8 | angles.append(wormpy.get_segment_angle(segment)) 9 | activations.append(wormpy.get_ventral_muscle_activation(segment)) 10 | print angles 11 | print activations 12 | wormpy.term() 13 | -------------------------------------------------------------------------------- /WormHost/wormpy.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormHost/wormpy.pyc -------------------------------------------------------------------------------- /WormRPi/Raspberry-Pi-GPIO-Layout-Model-B-Plus-rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormRPi/Raspberry-Pi-GPIO-Layout-Model-B-Plus-rotated.png -------------------------------------------------------------------------------- /WormRPi/Readme.txt: -------------------------------------------------------------------------------- 1 | C elegans worm robot Raspberry Pi Zero W code. 2 | 3 | Download Raspbian to SD boot card. 4 | 5 | To enable wireless, create wpa_supplicant.conf in boot directory with this content: 6 | country= 7 | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev 8 | update_config=1 9 | 10 | network={ 11 | ssid="" 12 | psk="" 13 | } 14 | 15 | To enable ssh, create file named "ssh" in boot directory. 16 | 17 | To find RPi IP: nmap -sn 192.168.1.0/24 18 | 19 | Enable I2C: 20 | https://www.abelectronics.co.uk/kb/article/1/i2c--smbus-and-raspbian-linux 21 | 22 | Login with ssh: 23 | ssh 24 | login=pi, password=raspberry 25 | 26 | Setup: 27 | 1. Create $HOME/robot directory on RPi: 28 | mkdir $HOME/robot 29 | 2. Copy python and segment_angles.txt files to $HOME/robot. 30 | 31 | Run scripts: servo_reset.py (straighten robot), worm_run.py, worm_run_angles.py, worm_run_segment_angles.py 32 | 33 | Ultrasonic distance sensor: 34 | 35 | Parallax Ping Ultrasonic distance sensor: 36 | https://www.parallax.com/sites/default/files/downloads/28015-PING-Sensor-Product-Guide-v2.0.pdf 37 | See: sonar.py 38 | 39 | Deprecated audio sensor: 40 | 41 | Audio microphone installation instructions: 42 | https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/ 43 | https://pinout.xyz/pinout/i2c# 44 | See: food_listener.py 45 | 46 | To set audio volume sensitivity: 47 | Copy asoundrc.txt to $HOME/.asoundrc on the robot. 48 | Run arecord first to "prime the pump" 49 | Then either: 50 | alsamixer 51 | F6 to select snd_rpi_simple_card 52 | F4 to set volume 53 | or 54 | amixer -M set Capture 50% 55 | Finally to make sensitivity persistent: 56 | sudo alsactl store 1 57 | 58 | To enable http communications with host: 59 | 1. Copy json files to $HOME/robot. 60 | 2. Start flask web server: python flask_app.py 61 | -------------------------------------------------------------------------------- /WormRPi/amplitudes.py: -------------------------------------------------------------------------------- 1 | """Usage: 2 | amplitudes WAV_FILE 3 | 4 | Returns the (linear) amplitude of the signal inside the wav file, sample by sample. 5 | """ 6 | from __future__ import division 7 | import docopt 8 | 9 | import scipy.io.wavfile 10 | 11 | MAX_WAV16_AMP = 32767 # = 2**15-1 # because wav16 is signed (wav8 isn't) 12 | 13 | 14 | def main(): 15 | args = docopt.docopt(__doc__) 16 | 17 | one_pos_to_neg_crossing_path = r"W:\materials\audio\one_pos_to_neg_crossing.wav" 18 | if False: args['WAV_FILE'] = one_pos_to_neg_crossing_path 19 | 20 | rate, amp_arr = scipy.io.wavfile.read(args['WAV_FILE']) 21 | for amp in (amp_arr / MAX_WAV16_AMP): 22 | print(amp) 23 | 24 | if __name__ == '__main__': 25 | main() 26 | -------------------------------------------------------------------------------- /WormRPi/arecord.sh: -------------------------------------------------------------------------------- 1 | arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono -v myfile.wav 2 | -------------------------------------------------------------------------------- /WormRPi/asoundrc.txt: -------------------------------------------------------------------------------- 1 | #The below 2 sections are commented, they control the default sound card to use 2 | #This set up is for a Pi with an I2S microphone attached using the guide 3 | #from adafruit at 4 | # https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout 5 | #Uncomment and the I2S will be your default card (assuming same setup) 6 | #but you won't get audio playback because both recording and playback will be 7 | #defaulted 8 | #TODO - Figure out how to set default for recording separately 9 | #To adjust use aplay -l to work out the devices you have and their card number 10 | #For recording devices use arecord -l 11 | 12 | #pcm.!default { 13 | # type hw 14 | # card 1 15 | #} 16 | 17 | #ctl.!default { 18 | # type hw 19 | # card 1 20 | #} 21 | 22 | #This section makes a reference to your I2S hardware, adjust the card name 23 | # to what is shown in arecord -l after card x: before the name in [] 24 | #You may have to adjust channel count also but stick with default first 25 | pcm.dmic_hw { 26 | type hw 27 | card sndrpisimplecar 28 | channels 2 29 | format S32_LE 30 | } 31 | 32 | #This is the software volume control, it links to the hardware above and after 33 | # saving the .asoundrc file you can type alsamixer, press F6 to select 34 | # your I2S mic then F4 to set the recording volume and arrow up and down 35 | # to adjust the volume 36 | # After adjusting the volume - go for 50 percent at first, you can do 37 | # something like 38 | # arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono -v myfile.wav 39 | pcm.dmic_sv { 40 | type softvol 41 | slave.pcm dmic_hw 42 | control { 43 | name "Boost Capture Volume" 44 | card sndrpisimplecar 45 | } 46 | min_dB -3.0 47 | max_dB 30.0 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /WormRPi/flask_app.py: -------------------------------------------------------------------------------- 1 | import flask 2 | from flask import Flask, json, jsonify, request, abort 3 | import json 4 | from Servo import Servo 5 | from time import sleep 6 | import food_listener 7 | 8 | robot = Servo() 9 | servo_list = [0, 1, 2, 3, 4, 5, 6, 7] 10 | servo_delay = 1 11 | 12 | app = Flask(__name__) 13 | 14 | @app.route('/') 15 | def index(): 16 | return 'Routes: robot/sensors, robot/food, and robot/muscles' 17 | 18 | @app.route('/robot/sensors', methods=['GET']) 19 | def get_sensors(): 20 | with open("sensors.json") as sensors_file: 21 | sensors_data = json.load(sensors_file) 22 | return jsonify({'sensors': sensors_data}) 23 | 24 | @app.route('/robot/food', methods=['GET']) 25 | def get_food(): 26 | volume = food_listener.listen() 27 | return jsonify({'volume': volume}) 28 | 29 | @app.route('/robot/muscles', methods=['POST']) 30 | def put_muscles(): 31 | if not request.json or not 'muscles' in request.json: 32 | abort(400) 33 | muscles = request.json.get('muscles', "") 34 | for i in servo_list: 35 | robot.set_servo ((11 - i), muscles[i]) 36 | #sleep(servo_delay) 37 | with open('muscles.json', "a") as muscles_file: 38 | muscles_file.write('{ "muscles" : %s }\n' % muscles) 39 | return "OK", 201 40 | 41 | if __name__ == '__main__': 42 | app.run(debug=True, host='0.0.0.0') 43 | -------------------------------------------------------------------------------- /WormRPi/food_listener.py: -------------------------------------------------------------------------------- 1 | # Listen for food audio. 2 | 3 | import os 4 | from scipy.io.wavfile import read 5 | import numpy 6 | 7 | def listen(): 8 | 9 | # Record audio. 10 | result = os.system("arecord -d 1 -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono food.wav >/dev/null 2>/dev/null") 11 | 12 | # Extract amplitudes. 13 | fs, data = read('food.wav') 14 | data = numpy.array(data).astype(float) 15 | data_size = len(data) 16 | 17 | # Extract mean of max amplitudes. 18 | amplitude_sample_size = 50 19 | amplitudes = [] 20 | idx = 0 21 | while idx < data_size: 22 | if data[idx][0] < 0: 23 | amplitudes.append((float)(abs(data[idx][0]))) 24 | idx += 1 25 | amplitudes.sort(key=float) 26 | amplitude_sum = 0.0 27 | amplitudes_size = len(amplitudes) 28 | idx = amplitudes_size - amplitude_sample_size 29 | while idx < amplitudes_size: 30 | amplitude_sum += amplitudes[idx] 31 | idx += 1 32 | return ((int)((amplitude_sum / (float)(amplitude_sample_size)) / 1000000)) 33 | 34 | if __name__ == '__main__': 35 | print listen() -------------------------------------------------------------------------------- /WormRPi/muscles.json: -------------------------------------------------------------------------------- 1 | { 2 | "muscles": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] 3 | } 4 | -------------------------------------------------------------------------------- /WormRPi/sensors.json: -------------------------------------------------------------------------------- 1 | { 2 | "salt": 0.0, 3 | "touch": 0.0 4 | } 5 | -------------------------------------------------------------------------------- /WormRPi/servo_reset.py: -------------------------------------------------------------------------------- 1 | from Servo import Servo #import servo class 2 | 3 | robot = Servo() #create instance of Servo 4 | 5 | #set first 8 servos to position 60 degree and set next 8 servos to -60 degrees 6 | robot.set_servo (0, 0) 7 | robot.set_servo (1, 0) 8 | robot.set_servo (2, 0) 9 | robot.set_servo (3, 0) 10 | robot.set_servo (4, 0) 11 | robot.set_servo (5, 0) 12 | robot.set_servo (6, 0) 13 | robot.set_servo (7, 0) 14 | robot.set_servo (8, 0) 15 | robot.set_servo (9, 0) 16 | robot.set_servo (10, 0) 17 | robot.set_servo (11, 0) 18 | robot.set_servo (12, 0) 19 | robot.set_servo (13, 0) 20 | robot.set_servo (14, 0) 21 | robot.set_servo (15, 0) 22 | -------------------------------------------------------------------------------- /WormRPi/servo_test.py: -------------------------------------------------------------------------------- 1 | from Servo import Servo #import servo class 2 | 3 | robot = Servo() #create instance of Servo 4 | 5 | #set first 8 servos to position 60 degree and set next 8 servos to -60 degrees 6 | robot.set_servo (0, 60) 7 | robot.set_servo (1, 60) 8 | robot.set_servo (2, 60) 9 | robot.set_servo (3, 60) 10 | robot.set_servo (4, 60) 11 | robot.set_servo (5, 60) 12 | robot.set_servo (6, 60) 13 | robot.set_servo (7, 60) 14 | robot.set_servo (8, -60) 15 | robot.set_servo (9, -60) 16 | robot.set_servo (10, -60) 17 | robot.set_servo (11, -60) 18 | robot.set_servo (12, -60) 19 | robot.set_servo (13, -60) 20 | robot.set_servo (14, -60) 21 | robot.set_servo (15, -60) 22 | -------------------------------------------------------------------------------- /WormRPi/sonar.py: -------------------------------------------------------------------------------- 1 | # Sonar distance to nearby object. 2 | # Using Parallax PING))) ultrasonic distance sensor. 3 | # https://www.parallax.com/sites/default/files/downloads/28015-PING-Sensor-Product-Guide-v2.0.pdf 4 | 5 | import time 6 | import RPi.GPIO as GPIO 7 | 8 | GPIO.setmode(GPIO.BOARD) 9 | 10 | timeout = 0.020 11 | 12 | def ping(): 13 | 14 | GPIO.setup(11, GPIO.OUT) 15 | #cleanup output 16 | GPIO.output(11, 0) 17 | 18 | time.sleep(0.000002) 19 | 20 | #send signal 21 | GPIO.output(11, 1) 22 | 23 | time.sleep(0.000005) 24 | 25 | GPIO.output(11, 0) 26 | 27 | GPIO.setup(11, GPIO.IN) 28 | 29 | goodread=True 30 | watchtime=time.time() 31 | while GPIO.input(11)==0 and goodread: 32 | starttime=time.time() 33 | if (starttime-watchtime > timeout): 34 | goodread=False 35 | 36 | if goodread: 37 | watchtime=time.time() 38 | while GPIO.input(11)==1 and goodread: 39 | endtime=time.time() 40 | if (endtime-watchtime > timeout): 41 | goodread=False 42 | 43 | if goodread: 44 | duration=endtime-starttime 45 | distance=duration*34000/2 46 | return distance 47 | else: 48 | return -1.0 49 | 50 | if __name__ == '__main__': 51 | print ping() -------------------------------------------------------------------------------- /WormRPi/test_audio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import pyaudio 3 | import wave 4 | 5 | CHUNK = 4096 6 | FORMAT = pyaudio.paInt32 7 | CHANNELS = 1 8 | RATE = 16000 9 | RECORD_SECONDS = 10 10 | WAVE_OUTPUT_FILENAME = "test.wav" 11 | 12 | p = pyaudio.PyAudio() 13 | 14 | stream = p.open(format=FORMAT, 15 | channels=CHANNELS, 16 | rate=RATE, 17 | input=True, 18 | frames_per_buffer=CHUNK) 19 | 20 | frames = [] 21 | 22 | for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)): 23 | data = stream.read(CHUNK) 24 | #print(data) 25 | #frames.append(data) 26 | 27 | stream.stop_stream() 28 | stream.close() 29 | p.terminate() 30 | 31 | -------------------------------------------------------------------------------- /WormRPi/wpa_supplicant.conf: -------------------------------------------------------------------------------- 1 | country=US 2 | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev 3 | update_config=1 4 | 5 | network={ 6 | ssid="quiddity" 7 | psk="ijk42ove" 8 | } 9 | -------------------------------------------------------------------------------- /WormSim/MatlabSupport/extractAndPlotEigenCurves.m: -------------------------------------------------------------------------------- 1 | %extract the eigenvectors 2 | %This assumes that the CSV file you are using has curves made up of angles 3 | %in it. If your curves are parameterized x(s), y(s) curves, this file will 4 | %not work. Enter the file name in the csvread's field 5 | [vecs,vals] = familyEigenVectorsFromAngles(csvread('../foodTracking.txt')); 6 | 7 | %plot the first four in a pretty way 8 | %plot the first four eigenworms 9 | figure(1) 10 | subplot(2,2,1) 11 | plot(linspace(0,1,length(vecs(:,end))),vecs(:,end)); 12 | xlabel('s'); 13 | ylabel('\theta'); 14 | title('Eigenworm 1'); 15 | subplot(2,2,2) 16 | plot(linspace(0,1,length(vecs(:,end))),vecs(:,end-1)); 17 | xlabel('s'); 18 | ylabel('\theta'); 19 | title('Eigenworm 2'); 20 | subplot(2,2,3) 21 | plot(linspace(0,1,length(vecs(:,end))),vecs(:,end-2)); 22 | xlabel('s'); 23 | ylabel('\theta'); 24 | title('Eigenworm 3'); 25 | subplot(2,2,4) 26 | plot(linspace(0,1,length(vecs(:,end))),vecs(:,end-3)); 27 | xlabel('s'); 28 | ylabel('\theta'); 29 | title('Eigenworm 4'); 30 | -------------------------------------------------------------------------------- /WormSim/MatlabSupport/familyEigenVectorsFromAngles.m: -------------------------------------------------------------------------------- 1 | %Given a number of curves specified by tangent angles, get the eigencurves 2 | 3 | % Inputs: curves: an nxm matrix of curves. n = # of curves, m = number of 4 | % points per curve 5 | 6 | % Outputs: the eigenvectors of the covariance matrix of the curves 7 | 8 | %In theory, this only has to be run once for a particular family of curves, then stored. 9 | 10 | function [vecs, vals] = familyEigenVectorsFromAngles(curves) 11 | %Next, compute the covariance matrix. 12 | covMtx = cov(curves); 13 | 14 | %Now find the eigenvectors, and we're done! 15 | [vecs,vals] = eig(covMtx); 16 | vals = diag(vals); 17 | end -------------------------------------------------------------------------------- /WormSim/Model/Makefile: -------------------------------------------------------------------------------- 1 | # WormSim makefile 2 | 3 | all: worm wormpy 4 | 5 | CC=g++ 6 | CXX=$(CC) -O2 -fPIC -I ../sundials-2.3.0/src/ida -I ../sundials-2.3.0/include -I ../sundials-2.3.0/src -Wno-deprecated 7 | LIBS=-L /usr/local/lib -l sundials_ida -l sundials_cvode -l sundials_nvecserial -lm 8 | SRCS=$(shell ls *.cpp) 9 | OBJS=$(subst .cpp,.o,$(SRCS)) 10 | 11 | worm: $(OBJS) 12 | $(CXX) $(OBJS) $(LIBS) -o worm 13 | 14 | wormpy: $(OBJS) wormpy.i 15 | swig -c++ -python wormpy.i 16 | $(CC) -O2 -fPIC -c wormpy_wrap.cxx -I/home/tom/anaconda2/include/python2.7 17 | $(CXX) -shared $(OBJS) wormpy_wrap.o $(LIBS) -o _wormpy.so 18 | 19 | check: 20 | @echo SRCS = $(SRCS) 21 | @echo OBJS = $(OBJS) 22 | 23 | clean: 24 | rm -rf $(TARGET) $(OBJS) 25 | 26 | depend: 27 | $(CXX) -MM $(SRCS) > .depends.mk 28 | 29 | -include .depends.mk 30 | -------------------------------------------------------------------------------- /WormSim/Model/Readme.txt: -------------------------------------------------------------------------------- 1 | wormpy is a SWIG (www.swig.org) python library. 2 | Notes: https://stackoverflow.com/questions/11693047/how-to-create-a-dll-with-swig-from-visual-studio-2010 3 | After building the library, run as follows: 4 | python worm_test.py 5 | 6 | 7 | -------------------------------------------------------------------------------- /WormSim/Model/gettime.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Get time in milliseconds since the initial call. 3 | */ 4 | 5 | #include "gettime.h" 6 | #include 7 | 8 | TIME gettime() 9 | { 10 | TIME t; 11 | 12 | #ifdef WIN32 13 | static TIME base_time = 0; 14 | if (base_time == 0) 15 | { 16 | base_time = (TIME)GetTickCount64(); 17 | return(0); 18 | } 19 | else 20 | { 21 | t = (TIME)GetTickCount64(); 22 | assert(t >= base_time); 23 | return(t - base_time); 24 | } 25 | #else 26 | static time_t base_sec = 0; 27 | static suseconds_t base_usec = 0; 28 | struct timeval tv; 29 | gettimeofday(&tv, NULL); 30 | if (base_sec == 0) 31 | { 32 | base_sec = tv.tv_sec; 33 | base_usec = tv.tv_usec; 34 | return(0); 35 | } 36 | else 37 | { 38 | t = (TIME)(((tv.tv_sec - base_sec) * 1000) + ((tv.tv_usec - base_usec) / 1000)); 39 | return(t); 40 | } 41 | #endif 42 | } 43 | -------------------------------------------------------------------------------- /WormSim/Model/gettime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Get time in milliseconds since the initial call. 3 | */ 4 | 5 | #ifdef _WIN32 6 | #ifndef WIN32 7 | #define WIN32 8 | #endif 9 | #endif 10 | 11 | #ifdef WIN32 12 | #include 13 | #else 14 | #include 15 | #include 16 | #include 17 | #endif 18 | 19 | typedef unsigned long long TIME; 20 | #define INVALID_TIME ((unsigned long long)(-1)) 21 | TIME gettime(); 22 | -------------------------------------------------------------------------------- /WormSim/Model/main.cpp: -------------------------------------------------------------------------------- 1 | // WormSim main. 2 | 3 | #include 4 | #include "wormsim.h" 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | if (!init_test()) 9 | { 10 | fprintf(stderr, "Cannot initialize\n"); 11 | return 1; 12 | } 13 | while (step()) {} 14 | term(); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /WormSim/Model/worm_run.py: -------------------------------------------------------------------------------- 1 | # Worm simulation. 2 | import sys 3 | sys.path.insert(1, 'Release') 4 | import wormpy 5 | wormpy.init() 6 | wormpy.step() 7 | activations = [] 8 | for segment in range(12) : 9 | activations.append(wormpy.get_ventral_muscle_activation(segment)); 10 | print activations 11 | wormpy.term() 12 | -------------------------------------------------------------------------------- /WormSim/Model/worm_test.py: -------------------------------------------------------------------------------- 1 | # Worm simulation test. 2 | import sys 3 | sys.path.insert(1, 'Release') 4 | import wormpy 5 | wormpy.init_test() 6 | wormpy.amplify_forward(1) 7 | #wormpy.amplify_turn(1.25) 8 | go = 1 9 | while go == 1 : 10 | go = wormpy.step() 11 | angles = [] 12 | activations = [] 13 | for segment in range(12) : 14 | angles.append(wormpy.get_segment_angle(segment)) 15 | activations.append(wormpy.get_ventral_muscle_activation(segment)) 16 | print(angles) 17 | #print activations 18 | wormpy.term() 19 | 20 | -------------------------------------------------------------------------------- /WormSim/Model/wormpy.i: -------------------------------------------------------------------------------- 1 | /* File: wormpy.i */ 2 | %module wormpy 3 | 4 | %{ 5 | #define SWIG_FILE_WITH_INIT 6 | #include "wormsim.h" 7 | %} 8 | 9 | // wormsim API. 10 | int init(); 11 | int init_test(); 12 | int step(); 13 | float get_segment_angle(int segment); 14 | float get_dorsal_muscle_activation(int segment); 15 | float get_ventral_muscle_activation(int segment); 16 | void term(); 17 | void amplify_forward(float amplifier); 18 | void amplify_turn(float amplifier); 19 | 20 | 21 | -------------------------------------------------------------------------------- /WormSim/Model/wormsim.h: -------------------------------------------------------------------------------- 1 | // WormSim API. 2 | int init(); 3 | int init_test(); 4 | int step(); 5 | float get_segment_angle(int segment); 6 | float get_dorsal_muscle_activation(int segment); 7 | float get_ventral_muscle_activation(int segment); 8 | void term(); 9 | 10 | // Motor neuron forward amplification. 11 | // 1=no amplification. 12 | void amplify_forward(float amplifier); 13 | 14 | // Motor neuron turn amplification. 15 | // 1=no amplification. 16 | void amplify_turn(float amplifier); 17 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/doc/cvode/cv_examples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormSim/sundials-2.3.0/doc/cvode/cv_examples.pdf -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/doc/cvode/cv_guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormSim/sundials-2.3.0/doc/cvode/cv_guide.pdf -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/doc/cvodes/cvs_examples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormSim/sundials-2.3.0/doc/cvodes/cvs_examples.pdf -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/doc/cvodes/cvs_guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormSim/sundials-2.3.0/doc/cvodes/cvs_guide.pdf -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/doc/ida/ida_examples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormSim/sundials-2.3.0/doc/ida/ida_examples.pdf -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/doc/ida/ida_guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormSim/sundials-2.3.0/doc/ida/ida_guide.pdf -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/doc/kinsol/kin_examples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormSim/sundials-2.3.0/doc/kinsol/kin_examples.pdf -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/doc/kinsol/kin_guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormSim/sundials-2.3.0/doc/kinsol/kin_guide.pdf -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/fcmix_parallel/README: -------------------------------------------------------------------------------- 1 | List of parallel CVODE FCMIX examples 2 | 3 | fcvnonx_p : diagonal ODE example - non-stiff case (ADAMS/FUNCTIONAL) 4 | fcvkryx_p : diagonal ODE example - stiff case (BDF/SPGMR) 5 | fcvkryx_bbd_p : diagonal ODE example - stiff case (BDF/SPGMR/FCVBBD) 6 | 7 | Sample results: 8 | 9 | SUNDIALS was built with the following options: 10 | 11 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 12 | 13 | System Architecture: IA-32 14 | Processor Type: Intel Pentium 4 Xeon DP (i686) 15 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 16 | C/Fortran Compilers: gcc/gfortran v4.1.0 17 | MPI Implementation: Open MPI v1.1 18 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/fcmix_parallel/fcvnonx_p.out: -------------------------------------------------------------------------------- 1 | Diagonal test problem: 2 | 3 | NEQ = 8 4 | parameter alpha = 1.250 5 | ydot_i = -alpha*i * y_i (i = 1,...,NEQ) 6 | RTOL, ATOL = 0.1E-04 0.1E-09 7 | Method is ADAMS/FUNCTIONAL 8 | Number of processors = 4 9 | 10 | 11 | t = 0.10D+00 no. steps = 14 no. f-s = 32 12 | t = 0.20D+00 no. steps = 22 no. f-s = 40 13 | t = 0.30D+00 no. steps = 29 no. f-s = 47 14 | t = 0.40D+00 no. steps = 37 no. f-s = 55 15 | t = 0.50D+00 no. steps = 44 no. f-s = 62 16 | t = 0.60D+00 no. steps = 51 no. f-s = 69 17 | t = 0.70D+00 no. steps = 59 no. f-s = 78 18 | t = 0.80D+00 no. steps = 66 no. f-s = 85 19 | t = 0.90D+00 no. steps = 74 no. f-s = 93 20 | t = 0.10D+01 no. steps = 81 no. f-s = 100 21 | 22 | Max. absolute error is 0.41E-07 23 | 24 | 25 | Final statistics: 26 | 27 | number of steps = 81 28 | number of f evals. = 100 29 | number of nonlinear iters. = 96 30 | number of nonlinear conv. failures = 0 31 | number of error test failures = 3 32 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/fcmix_serial/README: -------------------------------------------------------------------------------- 1 | List of serial CVODE FCMIX examples 2 | 3 | fcvdenx : chemical kinetics example (BDF/DENSE) 4 | fcvbanx : advection-diffusion example (BDF/BAND) 5 | fcvkryx : kinetics-transport example (BDF/SPGMR/User Prec) 6 | fcvkryx_bp : kinetics-transport example (BDF/SPGMR/FCVBP) 7 | 8 | Sample results: 9 | 10 | SUNDIALS was built with the following options: 11 | 12 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 13 | 14 | System Architecture: IA-32 15 | Processor Type: Intel Pentium 4 Xeon DP (i686) 16 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 17 | C/Fortran Compilers: gcc/gfortran v4.1.0 18 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/fcmix_serial/fcvbanx.out: -------------------------------------------------------------------------------- 1 | Band example problem: 2 | 3 | Advection-diffusion, NEQ = 50 4 | 5 | 6 | At t = 0.00 max.norm(u) = 0.895472E+02 7 | At t = 0.10 max.norm(u) = 0.413289E+01 NST = 85 8 | At t = 0.20 max.norm(u) = 0.103929E+01 NST = 103 9 | At t = 0.30 max.norm(u) = 0.297983E+00 NST = 113 10 | At t = 0.40 max.norm(u) = 0.876577E-01 NST = 120 11 | At t = 0.50 max.norm(u) = 0.262564E-01 NST = 126 12 | At t = 0.60 max.norm(u) = 0.783042E-02 NST = 130 13 | At t = 0.70 max.norm(u) = 0.232939E-02 NST = 134 14 | At t = 0.80 max.norm(u) = 0.695343E-03 NST = 137 15 | At t = 0.90 max.norm(u) = 0.211598E-03 NST = 140 16 | At t = 1.00 max.norm(u) = 0.655685E-04 NST = 142 17 | 18 | 19 | Final statistics: 20 | 21 | No. steps = 142 No. f-s = 174 No. J-s = 3 No. LU-s = 23 22 | No. nonlinear iterations = 170 23 | No. nonlinear convergence failures = 0 24 | No. error test failures = 3 25 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/fcmix_serial/fcvdenx.out: -------------------------------------------------------------------------------- 1 | Dense example problem: 2 | 3 | Robertson kinetics, NEQ = 3 4 | 5 | 6 | At t = 0.2639E+00 y = 0.989965E+00 0.347056E-04 0.100000E-01 7 | Above is a root, INFO() = 0 1 8 | At t = 0.4000E+00 y = 0.985164E+00 0.338624E-04 0.148021E-01 9 | At t = 0.4000E+01 y = 0.905510E+00 0.224034E-04 0.944679E-01 10 | At t = 0.4000E+02 y = 0.715795E+00 0.918349E-05 0.284196E+00 11 | At t = 0.4000E+03 y = 0.450542E+00 0.322296E-05 0.549455E+00 12 | At t = 0.4000E+04 y = 0.183188E+00 0.894132E-06 0.816811E+00 13 | At t = 0.4000E+05 y = 0.389787E-01 0.162157E-06 0.961021E+00 14 | At t = 0.4000E+06 y = 0.494002E-02 0.198572E-07 0.995060E+00 15 | At t = 0.4000E+07 y = 0.516511E-03 0.206710E-08 0.999483E+00 16 | At t = 0.2081E+08 y = 0.100000E-03 0.400039E-09 0.999900E+00 17 | Above is a root, INFO() = 1 0 18 | At t = 0.4000E+08 y = 0.520146E-04 0.208069E-09 0.999948E+00 19 | At t = 0.4000E+09 y = 0.520718E-05 0.208288E-10 0.999995E+00 20 | At t = 0.4000E+10 y = 0.510581E-06 0.204233E-11 0.999999E+00 21 | At t = 0.4000E+11 y = 0.451131E-07 0.180452E-12 0.100000E+01 22 | 23 | Final value of ydot = -0.851851E-18 -0.340740E-23 0.851854E-18 24 | 25 | 26 | Final statistics: 27 | 28 | No. steps = 515 No. f-s = 755 No. J-s = 12 No. LU-s = 110 29 | No. nonlinear iterations = 751 30 | No. nonlinear convergence failures = 0 31 | No. error test failures = 26 32 | No. root function evals = 543 33 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/parallel/README: -------------------------------------------------------------------------------- 1 | List of parallel CVODE examples 2 | 3 | cvnonx_p : 1-D advection-diffusion (nonstiff) 4 | cvkryx_p : 2-D 2-species diurnal advection-diffusion 5 | cvkryx_bbd_p : cvkryx_p with BBD preconditioner 6 | 7 | Sample results: 8 | 9 | SUNDIALS was built with the following options: 10 | 11 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 12 | 13 | System Architecture: IA-32 14 | Processor Type: Intel Pentium 4 Xeon DP (i686) 15 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 16 | C/Fortran Compilers: gcc/gfortran v4.1.0 17 | MPI Implementation: Open MPI v1.1 18 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/parallel/cvnonx_p.out: -------------------------------------------------------------------------------- 1 | 2 | 1-D advection-diffusion equation, mesh size = 10 3 | 4 | Number of PEs = 4 5 | 6 | At t = 0.00 max.norm(u) = 1.569909e+01 nst = 0 7 | At t = 0.50 max.norm(u) = 3.052881e+00 nst = 113 8 | At t = 1.00 max.norm(u) = 8.753188e-01 nst = 191 9 | At t = 1.50 max.norm(u) = 2.494926e-01 nst = 265 10 | At t = 2.00 max.norm(u) = 7.109707e-02 nst = 339 11 | At t = 2.50 max.norm(u) = 2.026223e-02 nst = 418 12 | At t = 3.00 max.norm(u) = 5.777332e-03 nst = 486 13 | At t = 3.50 max.norm(u) = 1.650483e-03 nst = 563 14 | At t = 4.00 max.norm(u) = 4.754357e-04 nst = 646 15 | At t = 4.50 max.norm(u) = 1.374222e-04 nst = 715 16 | At t = 5.00 max.norm(u) = 3.937469e-05 nst = 795 17 | 18 | Final Statistics: 19 | 20 | nst = 795 nfe = 1465 nni = 1461 ncfn = 146 netf = 5 21 | 22 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/serial/README: -------------------------------------------------------------------------------- 1 | List of serial CVODE examples 2 | 3 | cvdenx : dense example 4 | cvdenx_uw : dense example with user ewt function 5 | cvbanx : banded example 6 | cvkryx : Krylov example 7 | cvkryx_bp : Krylov example with banded preconditioner 8 | cvdirectdem : demonstration program for direct methods 9 | cvkrydem_lin : demonstration program with 3 Krylov solvers 10 | cvkrydem_pre : demonstration program for Krylov methods 11 | 12 | Sample results: 13 | 14 | SUNDIALS was built with the following options: 15 | 16 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 17 | 18 | System Architecture: IA-32 19 | Processor Type: Intel Pentium 4 Xeon DP (i686) 20 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 21 | C/Fortran Compilers: gcc/gfortran v4.1.0 22 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/serial/cvbanx.out: -------------------------------------------------------------------------------- 1 | 2 | 2-D Advection-Diffusion Equation 3 | Mesh dimensions = 10 X 5 4 | Total system size = 50 5 | Tolerance parameters: reltol = 0 abstol = 1e-05 6 | 7 | At t = 0 max.norm(u) = 8.954716e+01 8 | At t = 0.10 max.norm(u) = 4.132889e+00 nst = 85 9 | At t = 0.20 max.norm(u) = 1.039294e+00 nst = 103 10 | At t = 0.30 max.norm(u) = 2.979829e-01 nst = 113 11 | At t = 0.40 max.norm(u) = 8.765774e-02 nst = 120 12 | At t = 0.50 max.norm(u) = 2.625637e-02 nst = 126 13 | At t = 0.60 max.norm(u) = 7.830425e-03 nst = 130 14 | At t = 0.70 max.norm(u) = 2.329387e-03 nst = 134 15 | At t = 0.80 max.norm(u) = 6.953434e-04 nst = 137 16 | At t = 0.90 max.norm(u) = 2.115983e-04 nst = 140 17 | At t = 1.00 max.norm(u) = 6.556853e-05 nst = 142 18 | 19 | Final Statistics: 20 | nst = 142 nfe = 174 nsetups = 23 nfeLS = 0 nje = 3 21 | nni = 170 ncfn = 0 netf = 3 22 | 23 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/serial/cvdenx.out: -------------------------------------------------------------------------------- 1 | 2 | 3-species kinetics problem 3 | 4 | At t = 2.6391e-01 y = 9.899653e-01 3.470564e-05 1.000000e-02 5 | rootsfound[] = 0 1 6 | At t = 4.0000e-01 y = 9.851641e-01 3.386242e-05 1.480205e-02 7 | At t = 4.0000e+00 y = 9.055097e-01 2.240338e-05 9.446793e-02 8 | At t = 4.0000e+01 y = 7.157952e-01 9.183486e-06 2.841956e-01 9 | At t = 4.0000e+02 y = 4.505420e-01 3.222963e-06 5.494548e-01 10 | At t = 4.0000e+03 y = 1.831878e-01 8.941319e-07 8.168113e-01 11 | At t = 4.0000e+04 y = 3.897868e-02 1.621567e-07 9.610212e-01 12 | At t = 4.0000e+05 y = 4.940023e-03 1.985716e-08 9.950600e-01 13 | At t = 4.0000e+06 y = 5.165107e-04 2.067097e-09 9.994835e-01 14 | At t = 2.0807e+07 y = 1.000000e-04 4.000395e-10 9.999000e-01 15 | rootsfound[] = 1 0 16 | At t = 4.0000e+07 y = 5.201457e-05 2.080690e-10 9.999480e-01 17 | At t = 4.0000e+08 y = 5.207182e-06 2.082883e-11 9.999948e-01 18 | At t = 4.0000e+09 y = 5.105811e-07 2.042325e-12 9.999995e-01 19 | At t = 4.0000e+10 y = 4.511312e-08 1.804525e-13 1.000000e-00 20 | 21 | Final Statistics: 22 | nst = 515 nfe = 755 nsetups = 110 nfeLS = 0 nje = 12 23 | nni = 751 ncfn = 0 netf = 26 nge = 543 24 | 25 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvode/serial/cvdenx_uw.out: -------------------------------------------------------------------------------- 1 | 2 | 3-species kinetics problem 3 | 4 | At t = 2.6391e-01 y = 9.899653e-01 3.470564e-05 1.000000e-02 5 | rootsfound[] = 0 1 6 | At t = 4.0000e-01 y = 9.851641e-01 3.386242e-05 1.480205e-02 7 | At t = 4.0000e+00 y = 9.055097e-01 2.240338e-05 9.446793e-02 8 | At t = 4.0000e+01 y = 7.157952e-01 9.183486e-06 2.841956e-01 9 | At t = 4.0000e+02 y = 4.505420e-01 3.222963e-06 5.494548e-01 10 | At t = 4.0000e+03 y = 1.831878e-01 8.941319e-07 8.168113e-01 11 | At t = 4.0000e+04 y = 3.897868e-02 1.621567e-07 9.610212e-01 12 | At t = 4.0000e+05 y = 4.940023e-03 1.985716e-08 9.950600e-01 13 | At t = 4.0000e+06 y = 5.165107e-04 2.067097e-09 9.994835e-01 14 | At t = 2.0807e+07 y = 1.000000e-04 4.000395e-10 9.999000e-01 15 | rootsfound[] = 1 0 16 | At t = 4.0000e+07 y = 5.201457e-05 2.080690e-10 9.999480e-01 17 | At t = 4.0000e+08 y = 5.207182e-06 2.082883e-11 9.999948e-01 18 | At t = 4.0000e+09 y = 5.105811e-07 2.042325e-12 9.999995e-01 19 | At t = 4.0000e+10 y = 4.511312e-08 1.804525e-13 1.000000e-00 20 | 21 | Final Statistics: 22 | nst = 515 nfe = 755 nsetups = 110 nfeLS = 0 nje = 12 23 | nni = 751 ncfn = 0 netf = 26 nge = 543 24 | 25 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/parallel/README: -------------------------------------------------------------------------------- 1 | List of parallel CVODES examples 2 | 3 | (1) Simulation 4 | 5 | cvnonx_p : 1-D advection-diffusion (nonstiff) 6 | cvkryx_p : 2-D 2-species diurnal advection-diffusion 7 | cvkryx_bbd_p : cvkryx_p with BBD preconditioner 8 | 9 | (2) Forward sensitivity 10 | 11 | cvsfwdnonx_p : 1-D advection difusion PDE - 12 | Adams with Functional iteration 13 | cvsfwdkryx_p : 2-D 2-species diurnal advection-diffusion PDE - 14 | BDF with Newton GMRES 15 | 16 | (3) Adjoint sensitivity 17 | 18 | cvsadjnonx_p : 1-D advection-diffusion (nonstiff) 19 | cvsadjkryx_p : 2-D (or 3-D) advection-diffusion-reaction PDE 20 | BDF/SPGMR/BBD 21 | 22 | Sample results: 23 | 24 | SUNDIALS was built with the following options: 25 | 26 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 27 | 28 | System Architecture: IA-32 29 | Processor Type: Intel Pentium 4 Xeon DP (i686) 30 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 31 | C/Fortran Compilers: gcc/gfortran v4.1.0 32 | MPI Implementation: Open MPI v1.1 33 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/parallel/cvsadjkryx_p.out: -------------------------------------------------------------------------------- 1 | 2 | Parallel Krylov adjoint sensitivity analysis example 3 | 3D Advection diffusion PDE with homogeneous Neumann B.C. 4 | Computes gradient of G = int_t_Omega ( c_i^2 ) dt dOmega 5 | with respect to the source values at each grid point. 6 | 7 | Domain: 8 | 0.000000 < x < 20.000000 mx = 20 npe_x = 2 9 | 0.000000 < y < 20.000000 my = 40 npe_y = 2 10 | 0.000000 < z < 20.000000 mz = 20 npe_z = 1 11 | 12 | Begin forward integration... done. G = 8.232843e+03 13 | 14 | Final Statistics.. 15 | 16 | lenrw = 180946 leniw = 212 17 | llrw = 180856 lliw = 80 18 | nst = 118 19 | nfe = 125 nfel = 141 20 | nni = 121 nli = 141 21 | nsetups = 17 netf = 0 22 | npe = 2 nps = 234 23 | ncfn = 0 ncfl = 0 24 | 25 | Begin backward integration... done. 26 | 27 | Final Statistics.. 28 | 29 | lenrw = 361716 leniw = 212 30 | llrw = 180856 lliw = 80 31 | nst = 70 32 | nfe = 80 nfel = 133 33 | nni = 76 nli = 133 34 | nsetups = 15 netf = 0 35 | npe = 2 nps = 204 36 | ncfn = 0 ncfl = 0 37 | 38 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/parallel/cvsadjnonx_p.out: -------------------------------------------------------------------------------- 1 | 2 | g(tf) = 2.129919e-02 3 | 4 | dgdp(tf) 5 | [ 1]: -1.129221e+00 6 | [ 2]: -1.008885e+00 7 | 8 | mu(t0) 9 | [ 1]: 2.777306e-04 10 | [ 2]: 5.619708e-04 11 | [ 3]: 8.479539e-04 12 | [ 4]: 1.126399e-03 13 | [ 5]: 1.394128e-03 14 | [ 6]: 1.639588e-03 15 | [ 7]: 1.861653e-03 16 | [ 8]: 2.047373e-03 17 | [ 9]: 2.197987e-03 18 | [10]: 2.300248e-03 19 | [11]: 2.357877e-03 20 | [12]: 2.358565e-03 21 | [13]: 2.308409e-03 22 | [14]: 2.197306e-03 23 | [15]: 2.033385e-03 24 | [16]: 1.809938e-03 25 | [17]: 1.536549e-03 26 | [18]: 1.210884e-03 27 | [19]: 8.432127e-04 28 | [20]: 4.362377e-04 29 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/parallel/cvsnonx_p.out: -------------------------------------------------------------------------------- 1 | 2 | 1-D advection-diffusion equation, mesh size = 10 3 | 4 | Number of PEs = 4 5 | 6 | At t = 0.00 max.norm(u) = 1.569909e+01 nst = 0 7 | At t = 0.50 max.norm(u) = 3.052881e+00 nst = 113 8 | At t = 1.00 max.norm(u) = 8.753188e-01 nst = 191 9 | At t = 1.50 max.norm(u) = 2.494926e-01 nst = 265 10 | At t = 2.00 max.norm(u) = 7.109707e-02 nst = 339 11 | At t = 2.50 max.norm(u) = 2.026223e-02 nst = 418 12 | At t = 3.00 max.norm(u) = 5.777332e-03 nst = 486 13 | At t = 3.50 max.norm(u) = 1.650483e-03 nst = 563 14 | At t = 4.00 max.norm(u) = 4.754357e-04 nst = 646 15 | At t = 4.50 max.norm(u) = 1.374222e-04 nst = 715 16 | At t = 5.00 max.norm(u) = 3.937469e-05 nst = 795 17 | 18 | Final Statistics: 19 | 20 | nst = 795 nfe = 1465 nni = 1461 ncfn = 146 netf = 5 21 | 22 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/serial/README: -------------------------------------------------------------------------------- 1 | List of serial CVODES examples 2 | 3 | (1) Simulation 4 | 5 | cvdenx : dense example 6 | cvdenx_uw : dense example with user ewt function 7 | cvbanx : banded example 8 | cvkryx : Krylov example 9 | cvkryx_bp : Krylov example with banded preconditioner 10 | cvdirectdem : demonstration program for direct methods 11 | cvkrydem_lin : demonstration program with 3 Krylov solvers 12 | cvkrydem_pre : demonstration program for Krylov methods 13 | 14 | (2) Forward sensitivity 15 | 16 | cvsfwdnonx : 1-D advection difusion PDE - 17 | Adams with Functional iteration 18 | cvsfwddenx : chemical kinetics ODEs - 19 | BDF with Newton Dense 20 | cvsfwdkryx : 2-D 2-species diurnal advection-diffusion PDE - 21 | BDF with Newton GMRES 22 | 23 | (3) Adjoint sensitivity 24 | 25 | cvsadjdenx : chemical kinetics - adjoint sensitivity 26 | cvsadjbanx : advection-diffusion - adjoint sensitivity 27 | cvsadjkryx_int : food web - adjoint sensitivity for G 28 | cvsadjkryx_pnt : food web - adjoint sensitivity for g 29 | 30 | Sample results: 31 | 32 | SUNDIALS was built with the following options: 33 | 34 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 35 | 36 | System Architecture: IA-32 37 | Processor Type: Intel Pentium 4 Xeon DP (i686) 38 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 39 | C/Fortran Compilers: gcc/gfortran v4.1.0 40 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/serial/cvsadjbanx.out: -------------------------------------------------------------------------------- 1 | 2 | Create and allocate CVODES memory for forward runs 3 | 4 | Allocate global memory 5 | 6 | Forward integration 7 | 8 | Create and allocate CVODES memory for backward run 9 | 10 | Backward integration 11 | 12 | Maximum sensitivity 13 | lambda max = 1.128855e-01 14 | at 15 | x = 1.170732e+00 16 | y = 4.761905e-01 17 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/serial/cvsadjdenx.out: -------------------------------------------------------------------------------- 1 | 2 | Adjoint Sensitivity Example for Chemical Kinetics 3 | ------------------------------------------------- 4 | 5 | ODE: dy1/dt = -p1*y1 + p2*y2*y3 6 | dy2/dt = p1*y1 - p2*y2*y3 - p3*(y2)^2 7 | dy3/dt = p3*(y2)^2 8 | 9 | Find dG/dp for 10 | G = int_t0^tB0 g(t,p,y) dt 11 | g(t,p,y) = y3 12 | 13 | 14 | Create and allocate CVODES memory for forward runs 15 | Forward integration ... done ( nst = 810 ) 16 | -------------------------------------------------------- 17 | G: 3.9983e+07 18 | -------------------------------------------------------- 19 | 20 | Create and allocate CVODES memory for backward run 21 | Backward integration ... done ( nst = 230 ) 22 | -------------------------------------------------------- 23 | tB0: 4.0000e+07 24 | dG/dp: 7.6842e+05 -3.0691e+00 5.1145e-04 25 | lambda(t0): 3.9967e+07 3.9967e+07 3.9967e+07 26 | -------------------------------------------------------- 27 | 28 | Re-initialize CVODES memory for backward run 29 | Backward integration ... done ( nst = 197 ) 30 | -------------------------------------------------------- 31 | tB0: 5.0000e+01 32 | dG/dp: 1.7341e+02 -5.0591e-04 8.4323e-08 33 | lambda(t0): 8.4191e+00 1.6097e+01 1.6097e+01 34 | -------------------------------------------------------- 35 | 36 | Free memory 37 | 38 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/serial/cvsadjkryx_int.out: -------------------------------------------------------------------------------- 1 | 2 | Create and allocate CVODE memory for forward run 3 | 4 | Allocate global memory 5 | 6 | Forward integration 7 | 8 | G = int_t int_x int_y c6(t,x,y) dx dy dt = 422295.450105 9 | 10 | 11 | Create and allocate CVODES memory for backward run 12 | 13 | Backward integration 14 | 15 | Maximum sensitivity with respect to I.C. of species 1 16 | lambda max = 9.567021e+02 17 | at 18 | x = 1.000000e+00 19 | y = 1.000000e+00 20 | 21 | Maximum sensitivity with respect to I.C. of species 2 22 | lambda max = 9.377348e+02 23 | at 24 | x = 1.000000e+00 25 | y = 1.000000e+00 26 | 27 | Maximum sensitivity with respect to I.C. of species 3 28 | lambda max = 9.198138e+02 29 | at 30 | x = 1.000000e+00 31 | y = 1.000000e+00 32 | 33 | Maximum sensitivity with respect to I.C. of species 4 34 | lambda max = -3.936708e-03 35 | at 36 | x = 1.000000e+00 37 | y = 0.000000e+00 38 | 39 | Maximum sensitivity with respect to I.C. of species 5 40 | lambda max = -3.934202e-03 41 | at 42 | x = 1.000000e+00 43 | y = 0.000000e+00 44 | 45 | Maximum sensitivity with respect to I.C. of species 6 46 | lambda max = 2.843092e-01 47 | at 48 | x = 0.000000e+00 49 | y = 0.000000e+00 50 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/serial/cvsadjkryx_pnt.out: -------------------------------------------------------------------------------- 1 | 2 | Create and allocate CVODES memory for forward run 3 | 4 | Allocate global memory 5 | 6 | Forward integration 7 | 8 | g = int_x int_y c6(Tfinal,x,y) dx dy = 35988.916377 9 | 10 | 11 | Create and allocate CVODES memory for backward run 12 | 13 | Backward integration 14 | 15 | Maximum sensitivity with respect to I.C. of species 1 16 | mu max = 6.074957e-04 17 | at 18 | x = 1.000000e+00 19 | y = 1.000000e+00 20 | 21 | Maximum sensitivity with respect to I.C. of species 2 22 | mu max = 5.812681e-04 23 | at 24 | x = 1.000000e+00 25 | y = 1.000000e+00 26 | 27 | Maximum sensitivity with respect to I.C. of species 3 28 | mu max = 5.571946e-04 29 | at 30 | x = 1.000000e+00 31 | y = 1.000000e+00 32 | 33 | Maximum sensitivity with respect to I.C. of species 4 34 | mu max = 4.274343e-12 35 | at 36 | x = 1.000000e+00 37 | y = 2.631579e-01 38 | 39 | Maximum sensitivity with respect to I.C. of species 5 40 | mu max = 4.269644e-12 41 | at 42 | x = 1.000000e+00 43 | y = 2.631579e-01 44 | 45 | Maximum sensitivity with respect to I.C. of species 6 46 | mu max = 2.666027e-12 47 | at 48 | x = 1.000000e+00 49 | y = 2.631579e-01 50 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/serial/cvsbanx.out: -------------------------------------------------------------------------------- 1 | 2 | 2-D Advection-Diffusion Equation 3 | Mesh dimensions = 10 X 5 4 | Total system size = 50 5 | Tolerance parameters: reltol = 0 abstol = 1e-05 6 | 7 | At t = 0 max.norm(u) = 8.954716e+01 8 | At t = 0.10 max.norm(u) = 4.132889e+00 nst = 85 9 | At t = 0.20 max.norm(u) = 1.039294e+00 nst = 103 10 | At t = 0.30 max.norm(u) = 2.979829e-01 nst = 113 11 | At t = 0.40 max.norm(u) = 8.765774e-02 nst = 120 12 | At t = 0.50 max.norm(u) = 2.625637e-02 nst = 126 13 | At t = 0.60 max.norm(u) = 7.830425e-03 nst = 130 14 | At t = 0.70 max.norm(u) = 2.329387e-03 nst = 134 15 | At t = 0.80 max.norm(u) = 6.953434e-04 nst = 137 16 | At t = 0.90 max.norm(u) = 2.115983e-04 nst = 140 17 | At t = 1.00 max.norm(u) = 6.556853e-05 nst = 142 18 | 19 | Final Statistics: 20 | nst = 142 nfe = 174 nsetups = 23 nfeLS = 0 nje = 3 21 | nni = 170 ncfn = 0 netf = 3 22 | 23 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/serial/cvsdenx.out: -------------------------------------------------------------------------------- 1 | 2 | 3-species kinetics problem 3 | 4 | At t = 2.6391e-01 y = 9.899653e-01 3.470564e-05 1.000000e-02 5 | rootsfound[] = 0 1 6 | At t = 4.0000e-01 y = 9.851641e-01 3.386242e-05 1.480205e-02 7 | At t = 4.0000e+00 y = 9.055097e-01 2.240338e-05 9.446793e-02 8 | At t = 4.0000e+01 y = 7.157952e-01 9.183486e-06 2.841956e-01 9 | At t = 4.0000e+02 y = 4.505420e-01 3.222963e-06 5.494548e-01 10 | At t = 4.0000e+03 y = 1.831878e-01 8.941319e-07 8.168113e-01 11 | At t = 4.0000e+04 y = 3.897868e-02 1.621567e-07 9.610212e-01 12 | At t = 4.0000e+05 y = 4.940023e-03 1.985716e-08 9.950600e-01 13 | At t = 4.0000e+06 y = 5.165107e-04 2.067097e-09 9.994835e-01 14 | At t = 2.0807e+07 y = 1.000000e-04 4.000395e-10 9.999000e-01 15 | rootsfound[] = 1 0 16 | At t = 4.0000e+07 y = 5.201457e-05 2.080690e-10 9.999480e-01 17 | At t = 4.0000e+08 y = 5.207182e-06 2.082883e-11 9.999948e-01 18 | At t = 4.0000e+09 y = 5.105811e-07 2.042325e-12 9.999995e-01 19 | At t = 4.0000e+10 y = 4.511312e-08 1.804525e-13 1.000000e-00 20 | 21 | Final Statistics: 22 | nst = 515 nfe = 755 nsetups = 110 nfeLS = 0 nje = 12 23 | nni = 751 ncfn = 0 netf = 26 nge = 543 24 | 25 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/cvodes/serial/cvsdenx_uw.out: -------------------------------------------------------------------------------- 1 | 2 | 3-species kinetics problem 3 | 4 | At t = 2.6391e-01 y = 9.899653e-01 3.470564e-05 1.000000e-02 5 | rootsfound[] = 0 1 6 | At t = 4.0000e-01 y = 9.851641e-01 3.386242e-05 1.480205e-02 7 | At t = 4.0000e+00 y = 9.055097e-01 2.240338e-05 9.446793e-02 8 | At t = 4.0000e+01 y = 7.157952e-01 9.183486e-06 2.841956e-01 9 | At t = 4.0000e+02 y = 4.505420e-01 3.222963e-06 5.494548e-01 10 | At t = 4.0000e+03 y = 1.831878e-01 8.941319e-07 8.168113e-01 11 | At t = 4.0000e+04 y = 3.897868e-02 1.621567e-07 9.610212e-01 12 | At t = 4.0000e+05 y = 4.940023e-03 1.985716e-08 9.950600e-01 13 | At t = 4.0000e+06 y = 5.165107e-04 2.067097e-09 9.994835e-01 14 | At t = 2.0807e+07 y = 1.000000e-04 4.000395e-10 9.999000e-01 15 | rootsfound[] = 1 0 16 | At t = 4.0000e+07 y = 5.201457e-05 2.080690e-10 9.999480e-01 17 | At t = 4.0000e+08 y = 5.207182e-06 2.082883e-11 9.999948e-01 18 | At t = 4.0000e+09 y = 5.105811e-07 2.042325e-12 9.999995e-01 19 | At t = 4.0000e+10 y = 4.511312e-08 1.804525e-13 1.000000e-00 20 | 21 | Final Statistics: 22 | nst = 515 nfe = 755 nsetups = 110 nfeLS = 0 nje = 12 23 | nni = 751 ncfn = 0 netf = 26 nge = 543 24 | 25 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/fcmix_parallel/README: -------------------------------------------------------------------------------- 1 | List of parallel IDA FCMIX examples 2 | 3 | fidakryx_bbd_p : 2D heat equation (SPGMR w/FIDABBD preconditioner) 4 | 5 | Sample results: 6 | 7 | SUNDIALS was built with the following options: 8 | 9 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 10 | 11 | System Architecture: IA-32 12 | Processor Type: Intel Pentium 4 Xeon DP (i686) 13 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 14 | C/Fortran Compilers: gcc/gfortran v4.1.0 15 | MPI Implementation: Open MPI v1.1 16 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/fcmix_serial/README: -------------------------------------------------------------------------------- 1 | List of serial IDA FCMIX examples 2 | 3 | fidadenx : chemical kinetics example (DENSE) 4 | 5 | Sample results: 6 | 7 | SUNDIALS was built with the following options: 8 | 9 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 10 | 11 | System Architecture: IA-32 12 | Processor Type: Intel Pentium 4 Xeon DP (i686) 13 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 14 | C/Fortran Compilers: gcc/gfortran v4.1.0 15 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/fcmix_serial/fidadenx.out: -------------------------------------------------------------------------------- 1 | 2 | fidadenx: Robertson kinetics DAE serial exampleproblem for IDA 3 | Three equation chemicalkinetics problem. 4 | 5 | Tolerance parameters: rtol = 0.10E-03 atol = 0.10E-05 0.10E-09 0.10E-05 6 | Initial conditions y0 = ( 0.10E+01 0.00E+00 0.00E+00) 7 | 8 | t y1 y2 y3 nst k h 9 | 0.2640E+00 0.9900E+00 0.3471E-04 0.1000E-01 75 2 0.5716E-01 10 | Above is a root, INFO() = 0 1 11 | 0.4000E+00 0.9852E+00 0.3386E-04 0.1480E-01 77 3 0.1143E+00 12 | 0.4000E+01 0.9055E+00 0.2240E-04 0.9447E-01 91 4 0.3704E+00 13 | 0.4000E+02 0.7158E+00 0.9185E-05 0.2842E+00 127 4 0.2963E+01 14 | 0.4000E+03 0.4505E+00 0.3223E-05 0.5495E+00 177 3 0.1241E+02 15 | 0.4000E+04 0.1832E+00 0.8940E-06 0.8168E+00 228 3 0.2765E+03 16 | 0.4000E+05 0.3899E-01 0.1622E-06 0.9610E+00 278 5 0.2614E+04 17 | 0.4000E+06 0.4939E-02 0.1985E-07 0.9951E+00 324 5 0.2770E+05 18 | 0.4000E+07 0.5176E-03 0.2072E-08 0.9995E+00 355 4 0.3979E+06 19 | 0.2075E+08 0.1000E-03 0.4000E-09 0.9999E+00 374 4 0.1592E+07 20 | Above is a root, INFO() = 1 0 21 | 0.4000E+08 0.5191E-04 0.2076E-09 0.9999E+00 380 3 0.6366E+07 22 | 0.4000E+09 0.5882E-05 0.2353E-10 0.1000E+01 394 1 0.9167E+08 23 | 0.4000E+10 0.7054E-06 0.2822E-11 0.1000E+01 402 1 0.1467E+10 24 | 0.4000E+11 -0.7300E-06 -0.2920E-11 0.1000E+01 407 1 0.2347E+11 25 | 26 | Final Run Statistics: 27 | 28 | Number of steps = 407 29 | Number of residual evaluations = 557 30 | Number of Jacobian evaluations = 65 31 | Number of nonlinear iterations = 557 32 | Number of error test failures = 6 33 | Number of nonlinear conv. failures = 0 34 | Number of root function evals. = 437 35 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/parallel/README: -------------------------------------------------------------------------------- 1 | List of parallel IDA examples 2 | 3 | idakryx1_p : 2-D heat equation, diagonal preconditioner 4 | idakryx1_bbd_p : 2-D heat equation, BBD preconditioner 5 | idakryx2_p : 2-D food web, block-diagonal preconditioner 6 | idakryx2_bbd_p : 2-D food web, BBD preconditioner 7 | 8 | Sample results: 9 | 10 | SUNDIALS was built with the following options: 11 | 12 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 13 | 14 | System Architecture: IA-32 15 | Processor Type: Intel Pentium 4 Xeon DP (i686) 16 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 17 | C/Fortran Compilers: gcc/gfortran v4.1.0 18 | MPI Implementation: Open MPI v1.1 19 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/parallel/idakryx1_p.out: -------------------------------------------------------------------------------- 1 | 2 | idakryx1_p: Heat equation, parallel example problem for IDA 3 | Discretized heat equation on 2D unit square. 4 | Zero boundary conditions, polynomial initial conditions. 5 | Mesh dimensions: 10 x 10 Total system size: 100 6 | 7 | Subgrid dimensions: 5 x 5 Processor array: 2 x 2 8 | Tolerance parameters: rtol = 0 atol = 0.001 9 | Constraints set to force all solution components >= 0. 10 | SUPPRESSALG = TRUE to suppress local error testing on all boundary components. 11 | Linear solver: IDASPGMR Preconditioner: diagonal elements only. 12 | 13 | Output Summary (umax = max-norm of solution) 14 | 15 | time umax k nst nni nli nre nreLS h npe nps 16 | ---------------------------------------------------------------------- 17 | 0.00 9.75461e-01 0 0 0 0 0 0 0.00e+00 0 0 18 | 0.01 8.24106e-01 2 12 14 7 14 7 2.56e-03 8 21 19 | 0.02 6.88134e-01 3 15 18 12 18 12 5.12e-03 8 30 20 | 0.04 4.70711e-01 3 18 24 21 24 21 6.58e-03 9 45 21 | 0.08 2.16509e-01 3 22 29 30 29 30 1.32e-02 9 59 22 | 0.16 4.57687e-02 4 28 36 44 36 44 1.32e-02 9 80 23 | 0.32 2.09938e-03 4 35 44 67 44 67 2.63e-02 10 111 24 | 0.64 5.54028e-21 1 39 51 77 51 77 1.05e-01 12 128 25 | 1.28 3.85107e-20 1 41 53 77 53 77 4.21e-01 14 130 26 | 2.56 5.00523e-20 1 43 55 77 55 77 1.69e+00 16 132 27 | 5.12 1.50906e-19 1 44 56 77 56 77 3.37e+00 17 133 28 | 10.24 4.63224e-19 1 45 57 77 57 77 6.74e+00 18 134 29 | 30 | Error test failures = 1 31 | Nonlinear convergence failures = 0 32 | Linear convergence failures = 0 33 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/parallel/idakryx2_p.out: -------------------------------------------------------------------------------- 1 | 2 | idakryx2_p: Predator-prey DAE parallel example problem for IDA 3 | 4 | Number of species ns: 2 Mesh dimensions: 20 x 20 Total system size: 800 5 | Subgrid dimensions: 10 x 10 Processor array: 2 x 2 6 | Tolerance parameters: rtol = 1e-05 atol = 1e-05 7 | Linear solver: IDASPGMR Max. Krylov dimension maxl: 16 8 | Preconditioner: block diagonal, block size ns, via difference quotients 9 | CalcIC called to correct initial predator concentrations 10 | 11 | ----------------------------------------------------------- 12 | t bottom-left top-right | nst k h 13 | ----------------------------------------------------------- 14 | 15 | 0.00e+00 1.0000e+01 1.0000e+01 | 0 0 1.6310e-08 16 | 1.0000e+05 1.0000e+05 | 17 | 18 | 1.00e-03 1.0318e+01 1.0827e+01 | 33 4 9.7404e-05 19 | 1.0319e+05 1.0822e+05 | 20 | 21 | 1.00e-02 1.6189e+02 1.9735e+02 | 86 4 1.7533e-04 22 | 1.6189e+06 1.9735e+06 | 23 | 24 | 1.00e-01 2.4019e+02 2.7072e+02 | 162 1 4.0396e-02 25 | 2.4019e+06 2.7072e+06 | 26 | 27 | 4.00e-01 2.4019e+02 2.7072e+02 | 165 1 3.2316e-01 28 | 2.4019e+06 2.7072e+06 | 29 | 30 | 7.00e-01 2.4019e+02 2.7072e+02 | 166 1 6.4633e-01 31 | 2.4019e+06 2.7072e+06 | 32 | 33 | 1.00e+00 2.4019e+02 2.7072e+02 | 166 1 6.4633e-01 34 | 2.4019e+06 2.7072e+06 | 35 | 36 | ----------------------------------------------------------- 37 | 38 | Final statistics: 39 | 40 | Number of steps = 166 41 | Number of residual evaluations = 1257 42 | Number of nonlinear iterations = 206 43 | Number of error test failures = 0 44 | Number of nonlinear conv. failures = 0 45 | 46 | Number of linear iterations = 1049 47 | Number of linear conv. failures = 0 48 | 49 | Number of preconditioner setups = 25 50 | Number of preconditioner solves = 1257 51 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/serial/README: -------------------------------------------------------------------------------- 1 | List of serial IDA examples 2 | 3 | idadenx : 3-species Robertson kinetics system 4 | idabanx1 : 2-D heat equation, banded Jacobian 5 | idabanx2 : 2-D food web system, banded Jacobian 6 | idakryx : 2-D heat equation, diagonal preconditioner 7 | idakrydem_lin : demonstration program with 3 Krylov solvers 8 | 9 | Sample results: 10 | 11 | SUNDIALS was built with the following options: 12 | 13 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 14 | 15 | System Architecture: IA-32 16 | Processor Type: Intel Pentium 4 Xeon DP (i686) 17 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 18 | C/Fortran Compilers: gcc/gfortran v4.1.0 19 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/serial/idabanx1.out: -------------------------------------------------------------------------------- 1 | idabanx1: Heat equation, serial example problem for IDA 2 | Discretized heat equation on 2D unit square. 3 | Zero boundary conditions, polynomial initial conditions. 4 | Mesh dimensions: 10 x 10 Total system size: 100 5 | 6 | Tolerance parameters: rtol = 0 atol = 0.001 7 | Constraints set to force all solution components >= 0. 8 | Linear solver: IDABAND, banded direct solver 9 | difference quotient Jacobian, half-bandwidths = 10 10 | IDACalcIC called with input boundary values = 0.1 11 | 12 | Output Summary (umax = max-norm of solution) 13 | 14 | time umax k nst nni nje nre nreLS h 15 | . . . . . . . . . . . . . . . . . . . . . 16 | 0.00 9.75461e-01 0 0 1 2 3 42 1.00e-05 17 | 0.01 8.24113e-01 2 12 15 10 17 210 2.56e-03 18 | 0.02 6.88124e-01 3 15 19 10 21 210 5.12e-03 19 | 0.04 4.71054e-01 3 19 23 10 25 210 5.12e-03 20 | 0.08 2.16451e-01 3 23 28 11 30 231 1.02e-02 21 | 0.16 4.50382e-02 4 28 35 12 37 252 2.05e-02 22 | 0.32 2.14520e-03 5 34 43 13 45 273 4.10e-02 23 | 0.64 5.35703e-18 1 39 52 15 54 315 1.64e-01 24 | 1.28 1.79608e-32 1 41 54 17 56 357 6.55e-01 25 | 2.56 3.01356e-35 1 42 55 18 57 378 1.31e+00 26 | 5.12 6.46332e-37 1 43 56 19 58 399 2.62e+00 27 | 10.24 7.63174e-39 1 44 57 20 59 420 5.24e+00 28 | 29 | netf = 0, ncfn = 0 30 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/serial/idabanx2.out: -------------------------------------------------------------------------------- 1 | 2 | idabanx2: Predator-prey DAE serial example problem for IDA 3 | 4 | Number of species ns: 2 Mesh dimensions: 20 x 20 System size: 800 5 | Tolerance parameters: rtol = 1e-05 atol = 1e-05 6 | Linear solver: IDABAND, Band parameters mu = 40, ml = 40 7 | CalcIC called to correct initial predator concentrations. 8 | 9 | ----------------------------------------------------------- 10 | t bottom-left top-right | nst k h 11 | ----------------------------------------------------------- 12 | 13 | 0.00e+00 1.0000e+01 1.0000e+05 | 0 0 1.6310e-08 14 | 1.0000e+05 1.0000e+05 | 15 | 16 | 1.00e-03 1.0318e+01 1.0822e+05 | 32 4 1.0823e-04 17 | 1.0319e+05 1.0822e+05 | 18 | 19 | 1.00e-02 1.6188e+02 1.9734e+06 | 127 4 1.4203e-04 20 | 1.6189e+06 1.9734e+06 | 21 | 22 | 1.00e-01 2.4019e+02 2.7072e+06 | 235 1 3.9159e-02 23 | 2.4019e+06 2.7072e+06 | 24 | 25 | 4.00e-01 2.4019e+02 2.7072e+06 | 238 1 3.1327e-01 26 | 2.4019e+06 2.7072e+06 | 27 | 28 | 7.00e-01 2.4019e+02 2.7072e+06 | 239 1 6.2654e-01 29 | 2.4019e+06 2.7072e+06 | 30 | 31 | 1.00e+00 2.4019e+02 2.7072e+06 | 239 1 6.2654e-01 32 | 2.4019e+06 2.7072e+06 | 33 | 34 | ----------------------------------------------------------- 35 | Final run statistics: 36 | 37 | Number of steps = 239 38 | Number of residual evaluations = 3339 39 | Number of Jacobian evaluations = 36 40 | Number of nonlinear iterations = 421 41 | Number of error test failures = 3 42 | Number of nonlinear conv. failures = 0 43 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/ida/serial/idadenx.out: -------------------------------------------------------------------------------- 1 | 2 | idadenx: Robertson kinetics DAE serial example problem for IDA 3 | Three equation chemical kinetics problem. 4 | 5 | Linear solver: IDADENSE, with user-supplied Jacobian. 6 | Tolerance parameters: rtol = 0.0001 atol = 1e-08 1e-14 1e-06 7 | Initial conditions y0 = (1 0 0) 8 | Constraints and id not used. 9 | 10 | ----------------------------------------------------------------------- 11 | t y1 y2 y3 | nst k h 12 | ----------------------------------------------------------------------- 13 | 2.6403e-01 9.8997e-01 3.4706e-05 1.0000e-02 | 85 2 6.4537e-02 14 | rootsfound[] = 0 1 15 | 4.0000e-01 9.8517e-01 3.3864e-05 1.4796e-02 | 88 2 6.4537e-02 16 | 4.0000e+00 9.0550e-01 2.2403e-05 9.4473e-02 | 102 4 4.1426e-01 17 | 4.0000e+01 7.1582e-01 9.1851e-06 2.8417e-01 | 136 2 1.3422e+00 18 | 4.0000e+02 4.5049e-01 3.2226e-06 5.4950e-01 | 190 4 3.3557e+01 19 | 4.0000e+03 1.8321e-01 8.9429e-07 8.1679e-01 | 239 4 3.4533e+02 20 | 4.0000e+04 3.8984e-02 1.6218e-07 9.6102e-01 | 287 5 2.0140e+03 21 | 4.0000e+05 4.9389e-03 1.9852e-08 9.9506e-01 | 339 3 1.6788e+04 22 | 4.0000e+06 5.1683e-04 2.0684e-09 9.9948e-01 | 444 4 2.1755e+05 23 | 2.0793e+07 1.0000e-04 4.0004e-10 9.9990e-01 | 495 4 1.0146e+06 24 | rootsfound[] = 1 0 25 | 4.0000e+07 5.2036e-05 2.0816e-10 9.9995e-01 | 506 5 2.5503e+06 26 | 4.0000e+08 5.2103e-06 2.0841e-11 9.9999e-01 | 541 4 2.3847e+07 27 | 4.0000e+09 5.2125e-07 2.0850e-12 1.0000e-00 | 569 4 3.9351e+08 28 | 4.0000e+10 5.1091e-08 2.0437e-13 1.0000e-00 | 589 2 6.0246e+09 29 | 30 | Final Run Statistics: 31 | 32 | Number of steps = 589 33 | Number of residual evaluations = 832 34 | Number of Jacobian evaluations = 79 35 | Number of nonlinear iterations = 832 36 | Number of error test failures = 14 37 | Number of nonlinear conv. failures = 0 38 | Number of root fn. evaluations = 617 39 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/fcmix_parallel/README: -------------------------------------------------------------------------------- 1 | List of parallel KINSOL FCMIX examples 2 | 3 | fkinkryx_p : simple diagonal test with Fortran interface 4 | 5 | Sample result: 6 | 7 | SUNDIALS was built with the following options: 8 | 9 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 10 | 11 | System Architecture: IA-32 12 | Processor Type: Intel Pentium 4 Xeon DP (i686) 13 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 14 | C/Fortran Compilers: gcc/gfortran v4.1.0 (GCC) 15 | MPI Implementation: Open MPI v1.1 16 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/fcmix_parallel/fkinkryx_p.out: -------------------------------------------------------------------------------- 1 | Example program fkinkryx_p: 2 | 3 | This fkinsol example code solves a 128 eqn diagonal algebraic system. 4 | Its purpose is to demonstrate the use of the Fortran interface 5 | in a parallel environment. 6 | 7 | FKINSOL return code is 0 8 | 9 | The resultant values of uu (process 0) are: 10 | 11 | 1 1.000000 2.000000 3.000000 4.000000 12 | 5 5.000000 6.000000 7.000000 8.000000 13 | 9 9.000000 10.000000 11.000000 12.000000 14 | 13 13.000000 14.000000 15.000000 16.000000 15 | 17 17.000000 18.000000 19.000000 20.000000 16 | 21 21.000000 22.000000 23.000000 24.000000 17 | 25 25.000000 26.000000 27.000000 28.000000 18 | 29 29.000000 30.000000 31.000000 32.000000 19 | 20 | Final statistics: 21 | 22 | nni = 7, nli = 21 23 | nfe = 8, npe = 2 24 | nps = 28, ncfl = 0 25 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/fcmix_serial/README: -------------------------------------------------------------------------------- 1 | List of serial KINSOL FCMIX examples 2 | 3 | fkinkryx : simple diagonal test with Fortran interface 4 | 5 | Sample result: 6 | 7 | SUNDIALS was built with the following options: 8 | 9 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 10 | 11 | System Architecture: IA-32 12 | Processor Type: Intel Pentium 4 Xeon DP (i686) 13 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 14 | C/Fortran Compilers: gcc/gfortran v4.1.0 (GCC) 15 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/parallel/README: -------------------------------------------------------------------------------- 1 | List of parallel KINSOL examples 2 | 3 | kinkryx_p : 2-D food web system, block-diagonal preconditioner 4 | kinkryx_bbd_p : kinkryx_p problem with BBD preconditioner 5 | 6 | Sample results: 7 | 8 | SUNDIALS was built with the following options: 9 | 10 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 11 | 12 | System Architecture: IA-32 13 | Processor Type: Intel Pentium 4 Xeon DP (i686) 14 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 15 | C/Fortran Compilers: gcc/gfortran v4.1.0 (GCC) 16 | MPI Implementation: Open MPI v1.1 17 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/parallel/kinkryx_bbd_p.out: -------------------------------------------------------------------------------- 1 | 2 | Predator-prey test problem-- KINSol (parallel-BBD version) 3 | 4 | Mesh dimensions = 20 X 20 5 | Number of species = 6 6 | Total system size = 2400 7 | 8 | Subgrid dimensions = 10 X 10 9 | Processor array is 2 X 2 10 | 11 | Flag globalstrategy = 0 (0 = None, 1 = Linesearch) 12 | Linear solver is SPGMR with maxl = 20, maxlrst = 2 13 | Preconditioning uses band-block-diagonal matrix from KINBBDPRE 14 | Difference quotient half-bandwidths are mudq = 11, mldq = 11 15 | Retained band block half-bandwidths are mukeep = 6, mlkeep = 6 16 | Tolerance parameters: fnormtol = 1e-07 scsteptol = 1e-13 17 | 18 | Initial profile of concentration 19 | At all mesh points: 1 1 1 30000 30000 30000 20 | 21 | 22 | Computed equilibrium species concentrations: 23 | 24 | At bottom left: 25 | 1.165 1.165 1.165 34949 34949 34949 26 | 27 | At top right: 28 | 1.25552 1.25552 1.25552 37663.2 37663.2 37663.2 29 | 30 | Final Statistics.. 31 | nni = 9 nli = 464 32 | nfe = 10 nfeSG = 473 33 | nps = 473 npe = 1 ncfl = 6 34 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/parallel/kinkryx_p.out: -------------------------------------------------------------------------------- 1 | 2 | Predator-prey test problem -- KINSol (parallel version) 3 | 4 | Mesh dimensions = 20 X 20 5 | Number of species = 6 6 | Total system size = 2400 7 | 8 | Subgrid dimensions = 10 X 10 9 | Processor array is 2 X 2 10 | 11 | Flag globalstrategy = 0 (0 = None, 1 = Linesearch) 12 | Linear solver is SPGMR with maxl = 20, maxlrst = 2 13 | Preconditioning uses interaction-only block-diagonal matrix 14 | Tolerance parameters: fnormtol = 1e-07 scsteptol = 1e-13 15 | 16 | Initial profile of concentration 17 | At all mesh points: 1 1 1 30000 30000 30000 18 | 19 | 20 | Computed equilibrium species concentrations: 21 | 22 | At bottom left: 23 | 1.165 1.165 1.165 34949 34949 34949 24 | 25 | At top right: 26 | 1.25552 1.25552 1.25552 37663.2 37663.2 37663.2 27 | 28 | Final Statistics.. 29 | nni = 19 nli = 1140 30 | nfe = 20 nfeSG = 1159 31 | nps = 1159 npe = 2 ncfl = 19 32 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/serial/README: -------------------------------------------------------------------------------- 1 | List of serial KINSOL examples 2 | 3 | kindenx1 : Ferraris-Tronconi example (DENSE) 4 | kindenx2 : Robot kinematics problem (DENSE) 5 | kinbanx : 2-D elliptic PDE (BAND) 6 | kinkryx : 2-D food web system, block-diagonal preconditioner 7 | kinkrydem_lin : demonstration program with 3 Krylov solvers 8 | 9 | Sample result: 10 | 11 | SUNDIALS was built with the following options: 12 | 13 | ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples 14 | 15 | System Architecture: IA-32 16 | Processor Type: Intel Pentium 4 Xeon DP (i686) 17 | Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7) 18 | C/Fortran Compilers: gcc/gfortran v4.1.0 (GCC) 19 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/serial/kinbanx.out: -------------------------------------------------------------------------------- 1 | 2 | 2D elliptic PDE on unit square 3 | d^2 u / dx^2 + d^2 u / dy^2 = u^3 - u + 2.0 4 | + homogeneous Dirichlet boundary conditions 5 | 6 | Solution method: Modified Newton with band linear solver 7 | Problem size: 31 x 31 = 961 8 | 9 | Computed solution (||F|| = 1.37621e-12): 10 | 11 | 0.03125 0.12500 0.21875 0.31250 0.40625 0.50000 0.59375 0.68750 0.78125 0.87500 0.96875 12 | 13 | 0.03125 0.00405 0.01165 0.01617 0.01896 0.02051 0.02100 0.02051 0.01896 0.01617 0.01165 0.00405 14 | 0.12500 0.01165 0.03772 0.05461 0.06530 0.07126 0.07318 0.07126 0.06530 0.05461 0.03772 0.01165 15 | 0.21875 0.01617 0.05461 0.08098 0.09813 0.10780 0.11093 0.10780 0.09813 0.08098 0.05461 0.01617 16 | 0.31250 0.01896 0.06530 0.09813 0.11989 0.13229 0.13631 0.13229 0.11989 0.09813 0.06530 0.01896 17 | 0.40625 0.02051 0.07126 0.10780 0.13229 0.14632 0.15089 0.14632 0.13229 0.10780 0.07126 0.02051 18 | 0.50000 0.02100 0.07318 0.11093 0.13631 0.15089 0.15564 0.15089 0.13631 0.11093 0.07318 0.02100 19 | 0.59375 0.02051 0.07126 0.10780 0.13229 0.14632 0.15089 0.14632 0.13229 0.10780 0.07126 0.02051 20 | 0.68750 0.01896 0.06530 0.09813 0.11989 0.13229 0.13631 0.13229 0.11989 0.09813 0.06530 0.01896 21 | 0.78125 0.01617 0.05461 0.08098 0.09813 0.10780 0.11093 0.10780 0.09813 0.08098 0.05461 0.01617 22 | 0.87500 0.01165 0.03772 0.05461 0.06530 0.07126 0.07318 0.07126 0.06530 0.05461 0.03772 0.01165 23 | 0.96875 0.00405 0.01165 0.01617 0.01896 0.02051 0.02100 0.02051 0.01896 0.01617 0.01165 0.00405 24 | 25 | Final Statistics.. 26 | 27 | nni = 7 nfe = 8 28 | nbcfails = 0 nbacktr = 0 29 | nje = 1 nfeB = 63 30 | 31 | lenrw = 4822 leniw = 27 32 | lenrwB = 150877 leniwB = 961 33 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/serial/kindenx1.out: -------------------------------------------------------------------------------- 1 | 2 | Ferraris and Tronconi test problem 3 | Tolerance parameters: 4 | fnormtol = 1e-05 5 | scsteptol = 1e-05 6 | 7 | ------------------------------------------ 8 | 9 | Initial guess on lower bounds 10 | [x1,x2] = 0.25 1.5 11 | 12 | Exact Newton 13 | Solution: 14 | [x1,x2] = 0.299449 2.83693 15 | Final Statistics: 16 | nni = 3 nfe = 4 17 | nje = 3 nfeD = 18 18 | 19 | Exact Newton with line search 20 | Solution: 21 | [x1,x2] = 0.299449 2.83693 22 | Final Statistics: 23 | nni = 3 nfe = 4 24 | nje = 3 nfeD = 18 25 | 26 | Modified Newton 27 | Solution: 28 | [x1,x2] = 0.299449 2.83693 29 | Final Statistics: 30 | nni = 11 nfe = 12 31 | nje = 2 nfeD = 12 32 | 33 | Modified Newton with line search 34 | Solution: 35 | [x1,x2] = 0.299449 2.83693 36 | Final Statistics: 37 | nni = 11 nfe = 12 38 | nje = 2 nfeD = 12 39 | 40 | ------------------------------------------ 41 | 42 | Initial guess in middle of feasible region 43 | [x1,x2] = 0.625 3.89159 44 | 45 | Exact Newton 46 | Solution: 47 | [x1,x2] = 0.5 3.14159 48 | Final Statistics: 49 | nni = 5 nfe = 6 50 | nje = 5 nfeD = 30 51 | 52 | Exact Newton with line search 53 | Solution: 54 | [x1,x2] = 0.5 3.14159 55 | Final Statistics: 56 | nni = 5 nfe = 6 57 | nje = 5 nfeD = 30 58 | 59 | Modified Newton 60 | Solution: 61 | [x1,x2] = 0.500003 3.1416 62 | Final Statistics: 63 | nni = 12 nfe = 13 64 | nje = 2 nfeD = 12 65 | 66 | Modified Newton with line search 67 | Solution: 68 | [x1,x2] = 0.500003 3.1416 69 | Final Statistics: 70 | nni = 12 nfe = 13 71 | nje = 2 nfeD = 12 72 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/serial/kindenx2.out: -------------------------------------------------------------------------------- 1 | 2 | Robot Kinematics Example 3 | 8 variables; -1 <= x_i <= 1 4 | KINSOL problem size: 8 + 2*8 = 24 5 | 6 | Initial guess: 7 | l=x+1 x u=1-x 8 | ---------------------------------- 9 | 1 0.707107 1 10 | 1 0.707107 1 11 | 1 0.707107 1 12 | 1 0.707107 1 13 | 1 0.707107 1 14 | 1 0.707107 1 15 | 1 0.707107 1 16 | 1 0.707107 1 17 | 18 | Computed solution: 19 | l=x+1 x u=1-x 20 | ---------------------------------- 21 | 1.67155 0.671554 0.328446 22 | 1.74096 0.740955 0.259045 23 | 1.95189 0.951893 0.0481072 24 | 0.693569 -0.306431 1.30643 25 | 1.96381 0.963811 0.0361892 26 | 0.733413 -0.266587 1.26659 27 | 1.40464 0.404641 0.595359 28 | 1.91448 0.914475 0.0855246 29 | 30 | Final Statistics.. 31 | nni = 6 nfe = 7 32 | nje = 6 nfeD = 0 33 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/examples/kinsol/serial/kinkryx.out: -------------------------------------------------------------------------------- 1 | 2 | Predator-prey test problem -- KINSol (serial version) 3 | 4 | Mesh dimensions = 8 X 8 5 | Number of species = 6 6 | Total system size = 384 7 | 8 | Flag globalstrategy = 0 (0 = None, 1 = Linesearch) 9 | Linear solver is SPGMR with maxl = 15, maxlrst = 2 10 | Preconditioning uses interaction-only block-diagonal matrix 11 | Positivity constraints imposed on all components 12 | Tolerance parameters: fnormtol = 1e-07 scsteptol = 1e-13 13 | 14 | Initial profile of concentration 15 | At all mesh points: 1 1 1 30000 30000 30000 16 | 17 | 18 | Computed equilibrium species concentrations: 19 | 20 | At bottom left: 21 | 1.16428 1.16428 1.16428 34927.5 34927.5 34927.5 22 | 23 | At top right: 24 | 1.25797 1.25797 1.25797 37736.7 37736.7 37736.7 25 | 26 | Final Statistics.. 27 | nni = 10 nli = 378 28 | nfe = 11 nfeSG = 388 29 | nps = 388 npe = 1 ncfl = 7 30 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/include/sundials/sundials_fnvector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ----------------------------------------------------------------- 3 | * $Revision: 1.1 $ 4 | * $Date: 2006/07/05 15:27:52 $ 5 | * ----------------------------------------------------------------- 6 | * Programmer(s): Radu Serban and Aaron Collier @ LLNL 7 | * ----------------------------------------------------------------- 8 | * Copyright (c) 2002, The Regents of the University of California. 9 | * Produced at the Lawrence Livermore National Laboratory. 10 | * All rights reserved. 11 | * For details, see the LICENSE file. 12 | * ----------------------------------------------------------------- 13 | * This file (companion of nvector.h) contains definitions 14 | * needed for the initialization of vector operations in Fortran. 15 | * ----------------------------------------------------------------- 16 | */ 17 | 18 | 19 | #ifndef _FNVECTOR_H 20 | #define _FNVECTOR_H 21 | 22 | #ifdef __cplusplus /* wrapper to enable C++ usage */ 23 | extern "C" { 24 | #endif 25 | 26 | #ifndef _SUNDIALS_CONFIG_H 27 | #define _SUNDIALS_CONFIG_H 28 | #include 29 | #endif 30 | 31 | /* SUNDIALS solver IDs */ 32 | 33 | #define FCMIX_CVODE 1 34 | #define FCMIX_IDA 2 35 | #define FCMIX_KINSOL 3 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/src/sundials/sundials_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ----------------------------------------------------------------- 3 | * $Revision: 1.1 $ 4 | * $Date: 2006/07/05 15:32:38 $ 5 | * ----------------------------------------------------------------- 6 | * Programmer(s): Aaron Collier @ LLNL 7 | * ----------------------------------------------------------------- 8 | * Copyright (c) 2005, The Regents of the University of California. 9 | * Produced at the Lawrence Livermore National Laboratory. 10 | * All rights reserved. 11 | * For details, see the LICENSE file. 12 | *------------------------------------------------------------------ 13 | * SUNDIALS configuration header file 14 | *------------------------------------------------------------------ 15 | */ 16 | 17 | /* Define SUNDIALS version number */ 18 | #define SUNDIALS_PACKAGE_VERSION "2.3.0" 19 | 20 | /* FCMIX: Define Fortran name-mangling macro */ 21 | 22 | 23 | 24 | /* FCMIX: Define case of function names */ 25 | 26 | 27 | /* FCMIX: Define number of underscores to append to function names */ 28 | 29 | 30 | /* Define precision of SUNDIALS data type 'realtype' */ 31 | #define SUNDIALS_DOUBLE_PRECISION 1 32 | 33 | /* Use generic math functions */ 34 | #define SUNDIALS_USE_GENERIC_MATH 1 35 | 36 | /* FNVECTOR: Allow user to specify different MPI communicator */ 37 | 38 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/src/sundials/sundials_config.in: -------------------------------------------------------------------------------- 1 | /* 2 | * ----------------------------------------------------------------- 3 | * $Revision: 1.1 $ 4 | * $Date: 2006/07/05 15:32:38 $ 5 | * ----------------------------------------------------------------- 6 | * Programmer(s): Aaron Collier @ LLNL 7 | * ----------------------------------------------------------------- 8 | * Copyright (c) 2005, The Regents of the University of California. 9 | * Produced at the Lawrence Livermore National Laboratory. 10 | * All rights reserved. 11 | * For details, see the LICENSE file. 12 | *------------------------------------------------------------------ 13 | * SUNDIALS configuration header file 14 | *------------------------------------------------------------------ 15 | */ 16 | 17 | /* Define SUNDIALS version number */ 18 | #define SUNDIALS_PACKAGE_VERSION "@PACKAGE_VERSION@" 19 | 20 | /* FCMIX: Define Fortran name-mangling macro */ 21 | @F77_MANGLE_MACRO1@ 22 | @F77_MANGLE_MACRO2@ 23 | 24 | /* FCMIX: Define case of function names */ 25 | @F77_CASE@ 26 | 27 | /* FCMIX: Define number of underscores to append to function names */ 28 | @F77_UNDERSCORES@ 29 | 30 | /* Define precision of SUNDIALS data type 'realtype' */ 31 | @PRECISION_LEVEL@ 32 | 33 | /* Use generic math functions */ 34 | @GENERIC_MATH_LIB@ 35 | 36 | /* FNVECTOR: Allow user to specify different MPI communicator */ 37 | @F77_MPI_COMM_F2C@ 38 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/Contents.m: -------------------------------------------------------------------------------- 1 | % sundialsTB v.2.3.0 - Matlab interfaces to SUNDIALS solvers 2 | % 3 | % sundialsTB provides interfaces to the CVODES, IDA, and KINSOL 4 | % solvers in SUNDIALS. 5 | % 6 | % See also cvodes, idas, kinsol, nvector, putils -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVMonitorFn.m: -------------------------------------------------------------------------------- 1 | %CVMonitorFn - type for user provided monitoring function. 2 | % 3 | % The function MONFUN must be defined as 4 | % FUNCTION [] = MONFUN(CALL, T, Y, YQ, YS) 5 | % It is called after every internal CVode step and can be used to 6 | % monitor the progress of the solver. MONFUN is called with CALL=0 7 | % from CVodeMalloc at which time it should initialize itself and it 8 | % is called with CALL=2 from CVodeFree. Otherwise, CALL=1. 9 | % 10 | % It receives as arguments the current time T, solution vector Y, 11 | % and, if they were computed, quadrature vector YQ, and forward 12 | % sensitivity matrix YS. If YQ and/or YS were not computed they 13 | % are empty here. 14 | % 15 | % If additional data is needed inside MONFUN, it must be defined 16 | % as 17 | % FUNCTION NEW_MONDATA = MONFUN(CALL, T, Y, YQ, YS, MONDATA) 18 | % If the local modifications to the user data structure need to be 19 | % saved (e.g. for future calls to MONFUN), then MONFUN must set 20 | % NEW_MONDATA. Otherwise, it should set NEW_MONDATA=[] 21 | % (do not set NEW_MONDATA = DATA as it would lead to unnecessary copying). 22 | % 23 | % A sample monitoring function, CVodeMonitor, is provided with CVODES. 24 | % 25 | % See also CVodeSetOptions, CVodeMonitor 26 | % 27 | % NOTES: 28 | % 29 | % MONFUN is specified through the MonitorFn property in CVodeSetOptions. 30 | % If this property is not set, or if it is empty, MONFUN is not used. 31 | % MONDATA is specified through the MonitorData property in CVodeSetOptions. 32 | % 33 | % If MONFUN is used on the backward integration phase, YS will always be 34 | % empty. 35 | % 36 | % See CVodeMonitor for an example of using MONDATA to write a single 37 | % monitoring function that works both for the forward and backward 38 | % integration phases. 39 | 40 | % Radu Serban 41 | % Copyright (c) 2005, The Regents of the University of California. 42 | % $Revision: 1.2 $Date: 2006/03/07 01:19:50 $ 43 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVRhsFn.m: -------------------------------------------------------------------------------- 1 | %CVRhsFn - type for user provided RHS type 2 | % 3 | %IVP Problem 4 | % 5 | % The function ODEFUN must be defined as 6 | % FUNCTION [YD, FLAG] = ODEFUN(T,Y) 7 | % and must return a vector YD corresponding to f(t,y). 8 | % If a user data structure DATA was specified in CVodeMalloc, then 9 | % ODEFUN must be defined as 10 | % FUNCTION [YD, FLAG, NEW_DATA] = ODEFUN(T,Y,DATA) 11 | % If the local modifications to the user data structure are needed 12 | % in other user-provided functions then, besides setting the vector YD, 13 | % the ODEFUN function must also set NEW_DATA. Otherwise, it should set 14 | % NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 15 | % unnecessary copying). 16 | % 17 | % The function ODEFUN must set FLAG=0 if successful, FLAG<0 if an 18 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 19 | % occurred. 20 | % 21 | %Adjoint Problem 22 | % 23 | % The function ODEFUNB must be defined either as 24 | % FUNCTION [YBD, FLAG] = ODEFUNB(T,Y,YB) 25 | % or as 26 | % FUNCTION [YBD, FLAG, NEW_DATA] = ODEFUNB(T,Y,YB,DATA) 27 | % depending on whether a user data structure DATA was specified in 28 | % CVodeMalloc. In either case, it must return the vector YBD 29 | % corresponding to fB(t,y,yB). 30 | % 31 | % The function ODEFUNB must set FLAG=0 if successful, FLAG<0 if an 32 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 33 | % occurred. 34 | % 35 | % See also CVodeMalloc, CVodeMallocB 36 | % 37 | % NOTE: ODEFUN and ODEFUNB are specified through the CVodeMalloc and 38 | % CVodeMallocB functions, respectively. 39 | 40 | % Radu Serban 41 | % Copyright (c) 2005, The Regents of the University of California. 42 | % $Revision: 1.2 $Date: 2006/02/13 23:01:20 $ 43 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVRootFn.m: -------------------------------------------------------------------------------- 1 | %CVRootFn - type for user provided root-finding function. 2 | % 3 | % The function ROOTFUN must be defined as 4 | % FUNCTION [G, FLAG] = ROOTFUN(T,Y) 5 | % and must return a vector G corresponding to g(t,y). 6 | % If a user data structure DATA was specified in CVodeMalloc, then 7 | % ROOTFUN must be defined as 8 | % FUNCTION [G, FLAG, NEW_DATA] = ROOTFUN(T,Y,DATA) 9 | % If the local modifications to the user data structure are needed in 10 | % other user-provided functions then, besides setting the vector G, 11 | % the ROOTFUN function must also set NEW_DATA. Otherwise, it should 12 | % set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 13 | % unnecessary copying). 14 | % 15 | % The function ROOTFUN must set FLAG=0 if successful, or FLAG~=0 if 16 | % a failure occurred. 17 | % 18 | % See also CVodeSetOptions 19 | % 20 | % NOTE: ROOTFUN is specified through the RootsFn property in 21 | % CVodeSetOptions and is used only if the property NumRoots is a 22 | % positive integer. 23 | 24 | % Radu Serban 25 | % Copyright (c) 2005, The Regents of the University of California. 26 | % $Revision: 1.2 $Date: 2006/02/13 23:01:20 $ 27 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVSensRhsFn.m: -------------------------------------------------------------------------------- 1 | %CVSensRhsFn - type for user provided sensitivity RHS function. 2 | % 3 | % The function ODESFUN must be defined as 4 | % FUNCTION [YSD, FLAG] = ODESFUN(T,Y,YD,YS) 5 | % and must return a matrix YSD corresponding to fS(t,y,yS). 6 | % If a user data structure DATA was specified in CVodeMalloc, then 7 | % ODESFUN must be defined as 8 | % FUNCTION [YSD, FLAG, NEW_DATA] = ODESFUN(T,Y,YD,YS,DATA) 9 | % If the local modifications to the user data structure are needed in 10 | % other user-provided functions then, besides setting the matrix YSD, 11 | % the ODESFUN function must also set NEW_DATA. Otherwise, it should 12 | % set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 13 | % unnecessary copying). 14 | % 15 | % The function ODESFUN must set FLAG=0 if successful, FLAG<0 if an 16 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 17 | % occurred. 18 | % 19 | % See also CVodeSetFSAOptions 20 | % 21 | % NOTE: ODESFUN is specified through the property FSARhsFn to 22 | % CVodeSetFSAOptions. 23 | 24 | % Radu Serban 25 | % Copyright (c) 2005, The Regents of the University of California. 26 | % $Revision: 1.3 $Date: 2006/07/07 19:08:40 $ 27 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVadjMalloc.m: -------------------------------------------------------------------------------- 1 | function [] = CVadjMalloc(steps, interp) 2 | %CVadjMalloc allocates and initializes memory for ASA with CVODES. 3 | % 4 | % Usage: CVadjMalloc(STEPS, INTEPR) 5 | % 6 | % STEPS specifies the (maximum) number of integration steps between two 7 | % consecutive check points. 8 | % INTERP Specifies the type of interpolation used for estimating the forward 9 | % solution during the backward integration phase. INTERP should be 10 | % 'Hermite', indicating cubic Hermite interpolation, or 'Polynomial', 11 | % indicating variable order polynomial interpolation. 12 | 13 | % Radu Serban 14 | % Copyright (c) 2005, The Regents of the University of California. 15 | % $Revision: 1.2 $Date: 2006/03/15 19:31:25 $ 16 | 17 | mode = 3; 18 | 19 | cvm(mode,steps,interp); 20 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVodeFree.m: -------------------------------------------------------------------------------- 1 | function [] = CVodeFree() 2 | %CVodeFree deallocates memory for the CVODES solver. 3 | % 4 | % Usage: CVodeFree 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.3 $Date: 2006/10/11 18:12:36 $ 9 | 10 | mode = 40; 11 | cvm(mode); 12 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVodeMalloc.m: -------------------------------------------------------------------------------- 1 | function [] = CVodeMalloc(fct,t0,y0,varargin) 2 | %CVodeMalloc allocates and initializes memory for CVODES. 3 | % 4 | % Usage: CVodeMalloc ( ODEFUN, T0, Y0 [, OPTIONS [, DATA] ] ) 5 | % 6 | % ODEFUN is a function defining the ODE right-hand side: y' = f(t,y). 7 | % This function must return a vector containing the current 8 | % value of the righ-hand side. 9 | % T0 is the initial value of t. 10 | % Y0 is the initial condition vector y(t0). 11 | % OPTIONS is an (optional) set of integration options, created with 12 | % the CVodeSetOptions function. 13 | % DATA is (optional) problem data passed unmodified to all 14 | % user-provided functions when they are called. For example, 15 | % YD = ODEFUN(T,Y,DATA). 16 | % 17 | % See also: CVRhsFn 18 | 19 | % Radu Serban 20 | % Copyright (c) 2005, The Regents of the University of California. 21 | % $Revision: 1.2 $Date: 2006/07/07 19:08:40 $ 22 | 23 | mode = 1; 24 | 25 | if nargin < 3 26 | disp('CVodeMalloc:: too few parameters'); 27 | return 28 | end 29 | 30 | options = []; 31 | data =[]; 32 | if nargin > 3 33 | options = varargin{1}; 34 | end 35 | if nargin > 4 36 | data = varargin{2}; 37 | end 38 | 39 | cvm(mode,fct,t0,y0,options,data); 40 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVodeMallocB.m: -------------------------------------------------------------------------------- 1 | function [] = CVodeMallocB(fctB,tB0,yB0,varargin) 2 | %CVodeMallocB allocates and initializes backward memory for CVODES. 3 | % 4 | % Usage: CVodeMallocB ( FCTB, TB0, YB0 [, OPTIONSB] ) 5 | % 6 | % FCTB is a function defining the adjoint ODE right-hand side. 7 | % This function must return a vector containing the current 8 | % value of the adjoint ODE righ-hand side. 9 | % TB0 is the final value of t. 10 | % YB0 is the final condition vector yB(tB0). 11 | % OPTIONSB is an (optional) set of integration options, created with 12 | % the CVodeSetOptions function. 13 | % 14 | % See also: CVRhsFn 15 | % 16 | 17 | % Radu Serban 18 | % Copyright (c) 2005, The Regents of the University of California. 19 | % $Revision: 1.3 $Date: 2006/07/07 19:08:40 $ 20 | 21 | mode = 4; 22 | 23 | if nargin < 3 24 | disp('CVodeMallocB:: too few parameters'); 25 | return 26 | end 27 | 28 | options = []; 29 | if nargin == 4 30 | optionsB = varargin{1}; 31 | end 32 | 33 | cvm(mode,fctB,tB0,yB0,optionsB); 34 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVodeReInit.m: -------------------------------------------------------------------------------- 1 | function [] = CVodeReInit(fct,t0,y0,varargin) 2 | %CVodeReInit reinitializes memory for CVODES 3 | % where a prior call to CVodeMalloc has been made with the same 4 | % problem size N. CVodeReInit performs the same input checking 5 | % and initializations that CVodeMalloc does, but it does no 6 | % memory allocation, assuming that the existing internal memory 7 | % is sufficient for the new problem. 8 | % 9 | % Usage: CVodeReInit ( ODEFUN, T0, Y0 [, OPTIONS [, DATA] ] ) 10 | % 11 | % ODEFUN is a function defining the ODE right-hand side: y' = f(t,y). 12 | % This function must return a vector containing the current 13 | % value of the righ-hand side. 14 | % T0 is the initial value of t. 15 | % Y0 is the initial condition vector y(t0). 16 | % OPTIONS is an (optional) set of integration options, created with 17 | % the CVodeSetOptions function. 18 | % DATA is (optional) problem data passed unmodified to all 19 | % user-provided functions when they are called. For example, 20 | % YD = ODEFUN(T,Y,DATA). 21 | % 22 | % See also: CVodeMalloc, CVRhsFn 23 | 24 | % Radu Serban 25 | % Copyright (c) 2005, The Regents of the University of California. 26 | % $Revision: 1.2 $Date: 2006/07/07 19:08:40 $ 27 | 28 | mode = 11; 29 | 30 | if nargin < 3 31 | disp('CVodeReInit:: too few parameters'); 32 | return 33 | end 34 | 35 | options = []; 36 | data =[]; 37 | if nargin > 3 38 | options = varargin{1}; 39 | end 40 | if nargin > 4 41 | data = varargin{2}; 42 | end 43 | 44 | cvm(mode,fct,t0,y0,options,data); 45 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVodeReInitB.m: -------------------------------------------------------------------------------- 1 | function [] = CVodeReInitB(fctB,tB0,yB0,varargin) 2 | %CVodeReInitB allocates and initializes backward memory for CVODES. 3 | % where a prior call to CVodeMallocB has been made with the same 4 | % problem size NB. CVodeReInitB performs the same input checking 5 | % and initializations that CVodeMallocB does, but it does no 6 | % memory allocation, assuming that the existing internal memory 7 | % is sufficient for the new problem. 8 | % 9 | % Usage: CVodeReInitB ( FCTB, TB0, YB0 [, OPTIONSB] ) 10 | % 11 | % FCTB is a function defining the adjoint ODE right-hand side. 12 | % This function must return a vector containing the current 13 | % value of the adjoint ODE righ-hand side. 14 | % TB0 is the final value of t. 15 | % YB0 is the final condition vector yB(tB0). 16 | % OPTIONSB is an (optional) set of integration options, created with 17 | % the CVodeSetOptions function. 18 | % 19 | % See also: CVodeMallocB, CVRhsFn 20 | % 21 | 22 | % Radu Serban 23 | % Copyright (c) 2005, The Regents of the University of California. 24 | % $Revision: 1.3 $Date: 2006/07/07 19:08:40 $ 25 | 26 | mode = 14; 27 | 28 | if nargin < 3 29 | disp('CVodeReInitB:: too few parameters'); 30 | return 31 | end 32 | 33 | options = []; 34 | if nargin == 4 35 | optionsB = varargin{1}; 36 | end 37 | 38 | cvm(mode,fctB,tB0,yB0,optionsB); 39 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVodeSensMalloc.m: -------------------------------------------------------------------------------- 1 | function [] = CVodeSensMalloc(Ns,meth,yS0,varargin) 2 | %CVodeSensMalloc allocates and initializes memory for FSA with CVODES. 3 | % 4 | % Usage: CVodeSensMalloc ( NS, METH, YS0 [, OPTIONS ] ) 5 | % 6 | % NS is the number of parameters with respect to which sensitivities 7 | % are desired 8 | % METHOD FSA solution method [ 'Simultaneous' | {'Staggered'} ] 9 | % Specifies the FSA method for treating the nonlinear system solution for 10 | % sensitivity variables. In the simultaneous case, the nonlinear systems 11 | % for states and all sensitivities are solved simultaneously. In the 12 | % Staggered case, the nonlinear system for states is solved first and then 13 | % the nonlinear systems for all sensitivities are solved at the same time. 14 | % YS0 Initial conditions for sensitivity variables. 15 | % YS0 must be a matrix with N rows and Ns columns, where N is the problem 16 | % dimension and Ns the number of sensitivity systems. 17 | % OPTIONS is an (optional) set of FSA options, created with 18 | % the CVodeSetFSAOptions function. 19 | % 20 | 21 | % Radu Serban 22 | % Copyright (c) 2005, The Regents of the University of California. 23 | % $Revision: 1.1 $Date: 2006/03/07 01:19:50 $ 24 | 25 | mode = 2; 26 | 27 | if nargin < 3 28 | disp('CVodeSensMalloc:: too few parameters'); 29 | return 30 | end 31 | 32 | options = []; 33 | if nargin > 3 34 | options = varargin{1}; 35 | end 36 | 37 | cvm(mode,Ns,meth,yS0,options); 38 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVodeSensReInit.m: -------------------------------------------------------------------------------- 1 | function [] = CVodeSensReInit(meth,yS0,varargin) 2 | %CVodeSensReInit reinitializes CVODES's FSA-related memory 3 | % assuming it has already been allocated in prior calls to CVodeMalloc 4 | % and CVodeSensMalloc. 5 | % The number of sensitivities Ns is assumed to be unchanged since the 6 | % previous call to CVodeSensMalloc. 7 | % 8 | % Usage: CVodeSensReInit ( METH, YS0 [, OPTIONS ] ) 9 | % 10 | % METHOD FSA solution method [ 'Simultaneous' | {'Staggered'} ] 11 | % Specifies the FSA method for treating the nonlinear system solution for 12 | % sensitivity variables. In the simultaneous case, the nonlinear systems 13 | % for states and all sensitivities are solved simultaneously. In the 14 | % Staggered case, the nonlinear system for states is solved first and then 15 | % the nonlinear systems for all sensitivities are solved at the same time. 16 | % YS0 Initial conditions for sensitivity variables. 17 | % YS0 must be a matrix with N rows and Ns columns, where N is the problem 18 | % dimension and Ns the number of sensitivity systems. 19 | % OPTIONS is an (optional) set of FSA options, created with 20 | % the CVodeSetFSAOptions function. 21 | % 22 | % See also: CVodeSensMalloc 23 | 24 | % Radu Serban 25 | % Copyright (c) 2005, The Regents of the University of California. 26 | % $Revision: 1.1 $Date: 2006/03/07 01:19:50 $ 27 | 28 | mode = 12; 29 | 30 | if nargin < 2 31 | disp('CVodeSensReInit:: too few parameters'); 32 | return 33 | end 34 | 35 | options = []; 36 | if nargin > 2 37 | options = varargin{1}; 38 | end 39 | 40 | cvm(mode,0,meth,yS0,options); 41 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/CVodeSensToggleOff.m: -------------------------------------------------------------------------------- 1 | function [] = CVodeSensToggleOff() 2 | % CVodeSensToggleOff deactivates sensitivity calculations. 3 | % It does NOT deallocate sensitivity-related memory so that 4 | % sensitivity computations can be later toggled ON (through 5 | % CVodeSensReInit). 6 | % 7 | % Usage: CVodeSensToggleOff 8 | % 9 | % See also: CVodeSensMalloc, CVodeSensReInit 10 | 11 | % Radu Serban 12 | % Copyright (c) 2005, The Regents of the University of California. 13 | % $Revision: 1.2 $Date: 2006/07/07 19:08:40 $ 14 | 15 | mode = 13; 16 | cvm(mode); 17 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/Contents.m: -------------------------------------------------------------------------------- 1 | % MEX binding of CVODES functions 2 | % 3 | %-- Radu Serban @ LLNL -- April 2005 4 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_bjac.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = cvm_bjac(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | y = varargin{2}; 15 | fy = varargin{3}; 16 | fct = varargin{4}; 17 | data = varargin{5}; 18 | 19 | if isempty(data) 20 | [ret, flag] = feval(fct,t,y,fy); 21 | new_data = []; 22 | else 23 | [ret, flag, new_data] = feval(fct,t,y,fy,data); 24 | end 25 | 26 | case -1 27 | 28 | % Backward ODE 29 | 30 | t = varargin{1}; 31 | y = varargin{2}; 32 | yB = varargin{3}; 33 | fyB = varargin{4}; 34 | fct = varargin{5}; 35 | data = varargin{6}; 36 | 37 | if isempty(data) 38 | [ret, flag] = feval(fct,t,y,yB,fyB); 39 | new_data = []; 40 | else 41 | [ret, flag, new_data] = feval(fct,t,y,yB,fyB,data); 42 | end 43 | 44 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_djac.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = cvm_djac(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | y = varargin{2}; 15 | fy = varargin{3}; 16 | fct = varargin{4}; 17 | data = varargin{5}; 18 | 19 | if isempty(data) 20 | [ret, flag] = feval(fct,t,y,fy); 21 | new_data = []; 22 | else 23 | [ret, flag, new_data] = feval(fct,t,y,fy,data); 24 | end 25 | 26 | case -1 27 | 28 | % Backward ODE 29 | 30 | t = varargin{1}; 31 | y = varargin{2}; 32 | yB = varargin{3}; 33 | fyB = varargin{4}; 34 | fct = varargin{5}; 35 | data = varargin{6}; 36 | 37 | if isempty(data) 38 | [ret, flag] = feval(fct,t,y,yB,fyB); 39 | new_data = []; 40 | else 41 | [ret, flag, new_data] = feval(fct,t,y,yB,fyB,data); 42 | end 43 | 44 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_gcom.m: -------------------------------------------------------------------------------- 1 | function [flag, new_data] = cvm_gcom(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | y = varargin{2}; 15 | fct = varargin{3}; 16 | data = varargin{4}; 17 | 18 | if isempty(data) 19 | flag = feval(fct,t,y); 20 | new_data = []; 21 | else 22 | [flag, new_data] = feval(fct,t,y,data); 23 | end 24 | 25 | case -1 26 | 27 | % Backward ODE 28 | 29 | t = varargin{1}; 30 | y = varargin{2}; 31 | yB = varargin{3}; 32 | fct = varargin{4}; 33 | data = varargin{5}; 34 | 35 | if isempty(data) 36 | flag = feval(fct,t,y,yB); 37 | new_data = []; 38 | else 39 | [flag, new_data] = feval(fct,t,y,yB,data); 40 | end 41 | 42 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_gloc.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = cvm_gloc(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | y = varargin{2}; 15 | fct = varargin{3}; 16 | data = varargin{4}; 17 | 18 | if isempty(data) 19 | [ret, flag] = feval(fct,t,y); 20 | new_data = []; 21 | else 22 | [ret, flag, new_data] = feval(fct,t,y,data); 23 | end 24 | 25 | case -1 26 | 27 | % Backward ODE 28 | 29 | t = varargin{1}; 30 | y = varargin{2}; 31 | yB = varargin{3}; 32 | fct = varargin{4}; 33 | data = varargin{5}; 34 | 35 | if isempty(data) 36 | [ret, flag] = feval(fct,t,y,yB); 37 | new_data = []; 38 | else 39 | [ret, flag, new_data] = feval(fct,t,y,yB,data); 40 | end 41 | 42 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_jtv.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = cvm_jtv(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | y = varargin{2}; 15 | fy = varargin{3}; 16 | v = varargin{4}; 17 | fct = varargin{5}; 18 | data = varargin{6}; 19 | 20 | if isempty(data) 21 | [ret, flag] = feval(fct,t,y,fy,v); 22 | new_data = []; 23 | else 24 | [ret, flag, new_data] = feval(fct,t,y,fy,v,data); 25 | end 26 | 27 | case -1 28 | 29 | % Backward ODE 30 | 31 | t = varargin{1}; 32 | y = varargin{2}; 33 | yB = varargin{3}; 34 | fyB = varargin{4}; 35 | vB = varargin{5}; 36 | fct = varargin{6}; 37 | data = varargin{7}; 38 | 39 | if isempty(data) 40 | [ret, flag] = feval(fct,t,y,yB,fyB,vB); 41 | new_data =[]; 42 | else 43 | [ret, flag, new_data] = feval(fct,t,y,yB,fyB,vB,data); 44 | end 45 | 46 | 47 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_monitor.m: -------------------------------------------------------------------------------- 1 | function [new_mondata] = cvm_monitor(call, t, y, yQ, Ns, yS, fct, mondata) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | N = length(y); 8 | yS = reshape(yS,N,Ns); 9 | 10 | if isempty(mondata) 11 | feval(fct, call, t, y, yQ, yS); 12 | new_mondata = []; 13 | else 14 | new_mondata = feval(fct, call, t, y, yQ, yS, mondata); 15 | end 16 | 17 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_pset.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = cvm_pset(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | y = varargin{2}; 15 | fy = varargin{3}; 16 | jok = varargin{4}; 17 | gm = varargin{5}; 18 | fct = varargin{6}; 19 | data = varargin{7}; 20 | 21 | if isempty(data) 22 | [ret, flag] = feval(fct,t,y,fy,jok,gm); 23 | new_data = []; 24 | else 25 | [ret, flag, new_data] = feval(fct,t,y,fy,jok,gm,data); 26 | end 27 | 28 | case -1 29 | 30 | % Backward ODE 31 | 32 | t = varargin{1}; 33 | y = varargin{2}; 34 | yB = varargin{3}; 35 | fyB = varargin{4}; 36 | jokB = varargin{5}; 37 | gmB = varargin{6}; 38 | fct = varargin{7}; 39 | data = varargin{8}; 40 | 41 | if isempty(data) 42 | [ret, flag] = feval(fct,t,y,yB,fyB,jokB,gmB); 43 | new_data = []; 44 | else 45 | [ret, flag, new_data] = feval(fct,t,y,yB,fyB,jokB,gmB,data); 46 | end 47 | 48 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_psol.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = cvm_psol(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | y = varargin{2}; 15 | fy = varargin{3}; 16 | r = varargin{4}; 17 | fct = varargin{5}; 18 | data = varargin{6}; 19 | 20 | if isempty(data) 21 | [ret, flag] = feval(fct,t,y,fy,r); 22 | new_data = []; 23 | else 24 | [ret, flag, new_data] = feval(fct,t,y,fy,r,data); 25 | end 26 | 27 | case -1 28 | 29 | % Backward ODE 30 | 31 | t = varargin{1}; 32 | y = varargin{2}; 33 | yB = varargin{3}; 34 | fyB = varargin{4}; 35 | rB = varargin{5}; 36 | fct = varargin{6}; 37 | data = varargin{7}; 38 | 39 | if isempty(data) 40 | [ret, flag] = feval(fct,t,y,yB,fyB,rB); 41 | new_data = []; 42 | else 43 | [ret, flag, new_data] = feval(fct,t,y,yB,fyB,rB,data); 44 | end 45 | 46 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_rhs.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = cvm_rhs(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | y = varargin{2}; 15 | fct = varargin{3}; 16 | data = varargin{4}; 17 | 18 | if isempty(data) 19 | [ret, flag] = feval(fct,t,y); 20 | new_data = []; 21 | else 22 | [ret, flag, new_data] = feval(fct,t,y,data); 23 | end 24 | 25 | case -1 26 | 27 | % Backward ODE 28 | 29 | t = varargin{1}; 30 | y = varargin{2}; 31 | yB = varargin{3}; 32 | fct = varargin{4}; 33 | data = varargin{5}; 34 | 35 | if isempty(data) 36 | [ret, flag] = feval(fct,t,y,yB); 37 | new_data = []; 38 | else 39 | [ret, flag, new_data] = feval(fct,t,y,yB,data); 40 | end 41 | 42 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_rhsQ.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = cvm_rhsQ(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | y = varargin{2}; 15 | fct = varargin{3}; 16 | data = varargin{4}; 17 | 18 | if isempty(data) 19 | [ret, flag] = feval(fct,t,y); 20 | new_data =[]; 21 | else 22 | [ret, flag, new_data] = feval(fct,t,y,data); 23 | end 24 | 25 | case -1 26 | 27 | % Backward ODE 28 | 29 | t = varargin{1}; 30 | y = varargin{2}; 31 | yB = varargin{3}; 32 | fct = varargin{4}; 33 | data = varargin{5}; 34 | 35 | if isempty(data) 36 | [ret, flag] = feval(fct,t,y,yB); 37 | new_data = []; 38 | else 39 | [ret, flag, new_data] = feval(fct,t,y,yB,data); 40 | end 41 | 42 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_rhsS.m: -------------------------------------------------------------------------------- 1 | function [ySd, flag, new_data] = cvm_rhsS(t, y, yd, Ns, yS, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | N = length(y); 8 | yS = reshape(yS,N,Ns); 9 | 10 | if isempty(data) 11 | [ySd, flag] = feval(fct,t,y,yd,yS); 12 | new_data = []; 13 | else 14 | [ySd, flag, new_data] = feval(fct,t,y,yd,yS,data); 15 | end 16 | 17 | ySd = reshape(ySd,N*Ns,1); -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/cvm/cvm_root.m: -------------------------------------------------------------------------------- 1 | function [g, flag, new_data] = cvm_root(t, y, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | if isempty(data) 8 | [g, flag] = feval(fct,t,y); 9 | new_data = []; 10 | else 11 | [g, flag, new_data] = feval(fct,t,y,data); 12 | end 13 | 14 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_par/pvfnx_f.m: -------------------------------------------------------------------------------- 1 | function [ud, flag, new_data] = pvfnx_f(t, u, data) 2 | %PVFNX_F - RHS function for the PVFNX example problem 3 | % 4 | % See also: pvfnx, CVRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:25 $ 9 | 10 | % Extract needed problem constants from data 11 | 12 | dx = data.dx; 13 | hordc = data.p(1) / dx^2; 14 | horac = data.p(2) / (2.0*dx); 15 | 16 | % Extract parameters for parallel computation 17 | 18 | comm = data.comm; 19 | npes = data.npes; 20 | mype = data.mype; 21 | 22 | nlocal = length(u); 23 | 24 | % Compute related parameters 25 | 26 | mype_m1 = mype-1; 27 | mype_p1 = mype+1; 28 | last_pe = npes-1; 29 | 30 | % Local copy of state 31 | 32 | y = [0.0 ; u ; 0.0]; 33 | 34 | % Pass needed data to processes before and after current one 35 | 36 | if mype ~= 0 37 | MPI_Send(u(1), mype_m1, 0, comm); 38 | end 39 | if mype ~= last_pe 40 | MPI_Send(u(nlocal), mype_p1, 0, comm); 41 | end 42 | 43 | % Receive needed data from processes before and after current one 44 | 45 | buf = 0.0; 46 | 47 | if mype ~= 0 48 | MPI_Recv(buf, mype_m1, 0, comm); 49 | y(1) = buf; 50 | else 51 | y(1) = 0.0; % zero BC 52 | end 53 | 54 | if mype ~= last_pe 55 | MPI_Recv(buf, mype_p1, 0, comm); 56 | y(nlocal+2) = buf; 57 | else 58 | y(nlocal+2) = 0.0; % zero BC 59 | end 60 | 61 | for i = 2:nlocal+1 62 | ui = y(i); 63 | ul = y(i-1); 64 | ur = y(i+1); 65 | 66 | hdiff = hordc*(ul - 2.0*ui + ur); 67 | hadv = horac * (ur-ul); 68 | 69 | ud(i-1) = hdiff + hadv; 70 | 71 | end 72 | 73 | flag = 0; 74 | new_data = []; 75 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_par/pvkx_fl.m: -------------------------------------------------------------------------------- 1 | function [yd, flag, new_data] = pvkx_fl(t, y, data) 2 | %PVKX_FL - local RHS computation for the PVKX example problem. 3 | % 4 | % See also: pvkx, CVGlocalFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.3 $Date: 2006/03/07 01:19:52 $ 9 | 10 | xmin = data.xmin; 11 | ml = data.ml; 12 | start = data.start; 13 | dx = data.dx; 14 | Dc = data.Dc; 15 | yext = data.yext; 16 | 17 | for i = 2:ml(1)+1 18 | for j = 2:ml(2)+1 19 | for k = 2:ml(3)+1 20 | 21 | x = xmin + (start + [i-2 j-2 k-2] ) .* dx; 22 | v = velocity(x, data); 23 | s = source(x,data); 24 | 25 | [c, cl, cr] = stencil(yext,i,j,k); 26 | 27 | adv = v .* (cr-cl) ./ (2.0*dx); 28 | dif = Dc * (cr - 2.0*c + cl) / dx.^2; 29 | 30 | yd(i-1,j-1,k-1) = s + sum(dif-adv); 31 | 32 | end 33 | end 34 | end 35 | 36 | yd = reshape(yd,prod(ml),1); 37 | 38 | flag = 0; 39 | new_data = []; 40 | 41 | 42 | function [c,cl,cr] = stencil(yext,i,j,k) 43 | 44 | c = yext(i,j,k) * ones(1,3); 45 | cl(1) = yext(i-1,j, k ); cr(1) = yext(i+1,j, k ); 46 | cl(2) = yext(i, j-1,k ); cr(2) = yext(i, j+1,k ); 47 | cl(3) = yext(i, j, k-1); cr(3) = yext(i, j, k+1); 48 | 49 | 50 | function v = velocity(x, data) 51 | 52 | L = data.L; 53 | Vc = data.Vc; 54 | xmin = data.xmin; 55 | 56 | y = x(2) - xmin(2) - L; 57 | 58 | v(1) = Vc * (L+y) * (L-y); 59 | v(2) = 0.0; 60 | v(3) = 0.0; 61 | 62 | 63 | function s = source(x, data) 64 | 65 | A1 = data.A1; A2 = data.A2; 66 | S1 = data.S1; S2 = data.S2; 67 | X1 = data.X1; X2 = data.X2; 68 | Y1 = data.Y1; Y2 = data.Y2; 69 | Z1 = data.Z1; Z2 = data.Z2; 70 | 71 | s1 = A1 * exp(-(X1-x(1))^2/S1) * exp(-(Y1-x(2))^2/S1) * exp(-(Z1-x(3))^2/S1); 72 | s2 = A2 * exp(-(X2-x(1))^2/S2) * exp(-(Y2-x(2))^2/S2) * exp(-(Z2-x(3))^2/S2); 73 | 74 | s = s1 + s2; 75 | 76 | if s < data.GMIN 77 | s = 0.0; 78 | end 79 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_par/pvnx_f.m: -------------------------------------------------------------------------------- 1 | function [yd, flag, new_data] = pvnx_f(t, y, data) 2 | %PVNX_F - RHS functin for the PVNX exampel problem. 3 | % 4 | % see also: pvnx, CVRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:25 $ 9 | 10 | 11 | alpha = data.alpha; 12 | nlocal = data.nlocal; 13 | mype = data.mype; 14 | 15 | for i = 1:nlocal 16 | yd(i) = -alpha * (mype*nlocal + i) * y(i); 17 | end 18 | 19 | flag = 0; 20 | new_data = []; 21 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvbx_J.m: -------------------------------------------------------------------------------- 1 | function [J, flag, new_data] = cvbx_J(t, y, fy, data) 2 | %CVBX_J - Jacobian functino for the CVBX example problem. 3 | % 4 | % See also: cvbx, CVBandJacFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | mx = data.mx; 12 | my = data.my; 13 | hordc = data.hdcoef; 14 | horac = data.hacoef; 15 | verdc = data.vdcoef; 16 | 17 | mu = my; 18 | ml = my; 19 | mband = mu + 1 + ml; 20 | 21 | for i = 1:mx 22 | for j = 1:my 23 | k = j + (i-1)*my; 24 | J(mu+1,k) = -2.0 * (verdc + hordc); 25 | if i ~= 1 26 | J(1,k) = hordc + horac; 27 | end 28 | if i ~= mx 29 | J(mband,k) = hordc - horac; 30 | end 31 | if j ~= 1 32 | J(mu,k) = verdc; 33 | end 34 | if j ~= my 35 | J(mu+2,k) = verdc; 36 | end 37 | end 38 | end 39 | 40 | flag = 0; 41 | new_data = []; 42 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvbx_f.m: -------------------------------------------------------------------------------- 1 | function [ud, flag, new_data] = cvbx_f(t, u, data) 2 | %CVBX_F - RHS function for the CVBX example problem 3 | % 4 | % See also: cvbx, CVRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.3 $Date: 2006/03/07 01:19:54 $ 9 | 10 | mx = data.mx; 11 | my = data.my; 12 | hordc = data.hdcoef; 13 | horac = data.hacoef; 14 | verdc = data.vdcoef; 15 | 16 | for j = 1:my 17 | for i = 1:mx 18 | uij = u(j+(i-1)*my); 19 | if j == 1 20 | udn = 0.0; 21 | else 22 | udn = u(j-1+(i-1)*my); 23 | end 24 | if j == my 25 | uup = 0.0; 26 | else 27 | uup = u(j+1+(i-1)*my); 28 | end 29 | if i == 1 30 | ult = 0.0; 31 | else 32 | ult = u(j+(i-2)*my); 33 | end 34 | if i == mx 35 | urt = 0.0; 36 | else 37 | urt = u(j+i*my); 38 | end 39 | 40 | hdiff = hordc * (ult - 2*uij + urt); 41 | hadv = horac * (urt - ult); 42 | vdiff = verdc * (uup - 2*uij + udn); 43 | ud(j+(i-1)*my) = hdiff + hadv + vdiff; 44 | end 45 | end 46 | 47 | flag = 0; 48 | new_data = []; 49 | 50 | 51 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvbx_q.m: -------------------------------------------------------------------------------- 1 | function [qd, flag, new_data] = cvbx_q(t, u, data) 2 | %CVBX_Q - quadrature function for the CVBX example problem. 3 | % 4 | % See also: cvbx, CVQuadRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.3 $Date: 2006/03/07 01:19:54 $ 9 | 10 | 11 | mx = data.mx; 12 | my = data.my; 13 | dx = data.dx; 14 | dy = data.dy; 15 | xmax = data.xmax; 16 | ymax = data.ymax; 17 | 18 | qd1 = 0.0; 19 | for j = 1:my 20 | for i = 1:mx 21 | uij = u(j+(i-1)*my); 22 | if j == 1 | j == mx 23 | del_y = dy/2; 24 | else 25 | del_y = dy; 26 | end 27 | if i == 1 | i == mx 28 | del_x = dx/2; 29 | else 30 | del_x = dx; 31 | end 32 | qd1 = qd1 + uij * del_x*del_y; 33 | end 34 | end 35 | 36 | qd1 = qd1 / (xmax*ymax); 37 | 38 | qd(1) = qd1; 39 | 40 | flag = 0; 41 | new_data = []; 42 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvdiscx.m: -------------------------------------------------------------------------------- 1 | function [] = cvdiscx 2 | %CVDISCX - CVODES example with solution discontinuity 3 | % Trivial CVODES example to illustrate the use of 4 | % CVodeReInit to integrate over a discontinuity in 5 | % the solution: 6 | % y' = -y ; y(0) = 1 ; t = [0,1] 7 | % y' = -y ; y(1) = 1 ; t = [1,2] 8 | % 9 | 10 | % Radu Serban 11 | % Copyright (c) 2005, The Regents of the University of California. 12 | % $Revision: 1.1 $ 13 | 14 | t0 = 0.0; 15 | t1 = 1.0; 16 | t2 = 2.0; 17 | 18 | % Initialize solver 19 | y = 1.0; 20 | options = CVodeSetOptions('RelTol',1.e-3,... 21 | 'AbsTol',1.e-4,... 22 | 'StopTime',t1,... 23 | 'LinearSolver','Dense'); 24 | CVodeMalloc(@cvdiscx_f,t0,y,options); 25 | 26 | % Integrate to the point of discontinuity 27 | t = t0; 28 | i = 1; 29 | tt(i) = t0; yy(i) = y; 30 | while t < t1 31 | [status, t, y] = CVode(t1,'OneStepTstop'); 32 | i = i+1; 33 | tt(i) = t; 34 | yy(i) = y; 35 | end 36 | 37 | % Add discontinuity and reinitialize solver 38 | y = 1.0; 39 | options = CVodeSetOptions(options,'StopTime',t2); 40 | CVodeReInit(@cvdiscx_f,t1,y,options); 41 | 42 | % Integrate from discontinuity to final time 43 | t = t1; 44 | i = i+1; 45 | tt(i) = t1; yy(i) = y; 46 | while t < t2 47 | [status, t, y] = CVode(t2,'OneStepTstop'); 48 | i = i+1; 49 | tt(i) = t; 50 | yy(i) = y; 51 | end 52 | 53 | % Plot solution 54 | figure 55 | plot(tt,yy) 56 | title('Discontinuity in solution'); 57 | xlabel('time'); 58 | ylabel('y'); 59 | 60 | % Free memory 61 | CVodeFree; 62 | 63 | 64 | function [yd, flag] = cvdiscx_f(t, y) 65 | % RHS function for the CVDISCX example problem. 66 | 67 | yd(1) = -y(1); 68 | flag = 0; 69 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvdx_J.m: -------------------------------------------------------------------------------- 1 | function [J, flag, new_data] = cvdx_J(t, y, fy, data) 2 | %CVDX_J - Jacobian function for the CVDX, CVFDX, and CVADX example problems. 3 | % 4 | % see also: cvdx, cvfdx, cvadx, CVDenseJacFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | r1 = data.p(1); 12 | r2 = data.p(2); 13 | r3 = data.p(3); 14 | 15 | J(1,1) = -r1; 16 | J(1,2) = r2*y(3); 17 | J(1,3) = r2*y(2); 18 | 19 | J(2,1) = r1; 20 | J(2,2) = -r2*y(3) - 2*r3*y(2); 21 | J(2,3) = -r2*y(2); 22 | 23 | J(3,2) = 2*r3*y(2); 24 | 25 | flag = 0; 26 | new_data = []; 27 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvdx_JB.m: -------------------------------------------------------------------------------- 1 | function [JB, flag, new_data] = cvdx_JB(t, y, yB, fyB, data) 2 | %CVDX_JB - adjoint Jacobian for the CVADX example problem. 3 | % 4 | % See also: cvadx, CVDenseJacFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | J = cvdx_J(t,y,[],data); 12 | JB = -J'; 13 | 14 | flag = 0; 15 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvdx_f.m: -------------------------------------------------------------------------------- 1 | function [yd, flag, new_data] = cvdx_f(t, y, data) 2 | %CVDX_F - RHS function for the CVDX, CVFDX, and CVADX example problems. 3 | % 4 | % See also: cvdx, cvfdx, cvadx, CVRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | r1 = data.p(1); 12 | r2 = data.p(2); 13 | r3 = data.p(3); 14 | 15 | yd(1) = -r1*y(1) + r2*y(2)*y(3); 16 | yd(3) = r3*y(2)*y(2); 17 | yd(2) = -yd(1) - yd(3); 18 | 19 | flag = 0; 20 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvdx_fB.m: -------------------------------------------------------------------------------- 1 | function [yBd, flag, new_data] = cvdx_fB(t, y, yB, data) 2 | %CVDX_FB - adjoint RHS functin for the CVADX example problem. 3 | % 4 | % See alaos: cvadx, CVRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | r1 = data.p(1); 12 | r2 = data.p(2); 13 | r3 = data.p(3); 14 | 15 | y1 = y(1); 16 | y2 = y(2); 17 | y3 = y(3); 18 | 19 | l1 = yB(1); 20 | l2 = yB(2); 21 | l3 = yB(3); 22 | 23 | l21 = l2-l1; 24 | l32 = l3-l2; 25 | y23 = y2*y3; 26 | 27 | yBd(1) = - r1*l21; 28 | yBd(2) = r2*y3*l21 - 2.0*r3*y2*l32; 29 | yBd(3) = r2*y2*l21 - 1.0; 30 | 31 | flag = 0; 32 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvdx_fS.m: -------------------------------------------------------------------------------- 1 | function [ySd, flag, new_data] = cvdx_fS(t,y,yd,yS,data) 2 | %CVDX_FS - sensitivity RHS function for the CVFDX example problem. 3 | % It returns the right-hand sides of the sensitivity equations 4 | % with respect to r1 and r2. 5 | % YS and YSD are NxNs = 3x2 matrices 6 | % 7 | % See also: cvfdx, CVSensRhsFn 8 | 9 | % Radu Serban 10 | % Copyright (c) 2005, The Regents of the University of California. 11 | % $Revision: 1.3 $Date: 2006/03/07 01:19:54 $ 12 | 13 | 14 | r1 = data.p(1); 15 | r2 = data.p(2); 16 | r3 = data.p(3); 17 | 18 | % r1 19 | 20 | yS1 = yS(:,1); 21 | yS1d = zeros(3,1); 22 | 23 | yS1d(1) = -r1*yS1(1) + r2*y(3)*yS1(2) + r2*y(2)*yS1(3); 24 | yS1d(3) = 2*r3*y(2)*yS1(2); 25 | yS1d(2) = -yS1d(1)-yS1d(3); 26 | 27 | yS1d(1) = yS1d(1) - y(1); 28 | yS1d(2) = yS1d(2) + y(1); 29 | 30 | % r2 31 | 32 | yS2 = yS(:,2); 33 | yS2d = zeros(3,1); 34 | 35 | yS2d(1) = -r1*yS2(1) + r2*y(3)*yS2(2) + r2*y(2)*yS2(3); 36 | yS2d(3) = 2*r3*y(2)*yS2(2); 37 | yS2d(2) = -yS2d(1)-yS2d(3); 38 | 39 | yS2d(1) = yS2d(1) + y(2)*y(3); 40 | yS2d(2) = yS2d(2) - y(2)*y(3); 41 | 42 | % Return values 43 | 44 | ySd = [yS1d yS2d]; 45 | flag = 0; 46 | new_data = []; 47 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvdx_g.m: -------------------------------------------------------------------------------- 1 | function [g, flag, new_data] = cvdx_g(t,y,data) 2 | %CVDX_G - Root-finding function for the CVDX example problem. 3 | % 4 | % See also: cvdx, CVRootFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | g(1) = y(1) - 0.0001; 12 | g(2) = y(3) - 0.01; 13 | 14 | flag = 0; 15 | new_data = []; 16 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvdx_q.m: -------------------------------------------------------------------------------- 1 | function [qd, flag, new_data] = cvdx_q(t, y, data) 2 | %CVDX_Q - quadrature function for the CVADX example problem. 3 | % 4 | % See also: cvadx, CVQuadRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | qd = y(3); 12 | 13 | flag = 0; 14 | new_data = []; 15 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvdx_qB.m: -------------------------------------------------------------------------------- 1 | function [qBd, flag, new_data] = cvdx_qB(t, y, yB, data) 2 | %CVDX_QB - adjoint quadrature function for the CVADX example problem. 3 | % 4 | % See also: cavdx, CVQuadRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | r1 = data.p(1); 11 | r2 = data.p(2); 12 | r3 = data.p(3); 13 | 14 | y1 = y(1); 15 | y2 = y(2); 16 | y3 = y(3); 17 | 18 | l1 = yB(1); 19 | l2 = yB(2); 20 | l3 = yB(3); 21 | 22 | l21 = l2-l1; 23 | l32 = l3-l2; 24 | y23 = y2*y3; 25 | 26 | qBd(1) = y1*l21; 27 | qBd(2) = -y23*l21; 28 | qBd(3) = l32*y2^2; 29 | 30 | flag = 0; 31 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvkx_pset.m: -------------------------------------------------------------------------------- 1 | function [jcur, flag, data] = cvkx_pset(t,u,fu,jok,gm,data) 2 | %CVKX_PSET - Preconditioner setup function for the CVKX example problem. 3 | % 4 | % See also: cvkx, CVPrecSetupFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | persistent Jbd 11 | 12 | mx = data.mx; 13 | my = data.my; 14 | 15 | if jok 16 | 17 | % Copy Jbd to P 18 | 19 | P = Jbd; 20 | jcur = false; 21 | 22 | else 23 | 24 | % Generate Jbd from scratch and copy to P 25 | 26 | xmin = data.xmin; 27 | dx = data.dx; 28 | 29 | ymin = data.ymin; 30 | dy = data.dy; 31 | 32 | om = data.om; 33 | q1 = data.q1; 34 | q2 = data.q2; 35 | c3 = data.c3; 36 | a3 = data.a3; 37 | a4 = data.a4; 38 | hdco = data.hdco; 39 | haco = data.haco; 40 | vdco = data.vdco; 41 | 42 | s = sin(om*t); 43 | if s > 0.0 44 | q4 = exp(-a4/s); 45 | else 46 | q4 = 0.0; 47 | end 48 | 49 | u = reshape(u,2,mx*my); 50 | 51 | for jy = 1:my 52 | ydn = ymin + (jy - 1.5)*dy; 53 | yup = ydn + dy; 54 | cydn = vdco * exp(0.2*ydn); 55 | cyup = vdco * exp(0.2*yup); 56 | diag = -(cydn + cyup + 2.0*hdco); 57 | i = (jy-1)*mx; 58 | for jx = 1:mx 59 | ii = i + jx; 60 | c1 = u(1,ii); 61 | c2 = u(2,ii); 62 | Jbd(1,1,ii) = (-q1*c3 - q2*c2) + diag; 63 | Jbd(1,2,ii) = -q2*c1 + q4; 64 | Jbd(2,1,ii) = q1*c3 - q2*c2; 65 | Jbd(2,2,ii) = (-q2*c1 - q4) + diag; 66 | end 67 | end 68 | 69 | P = Jbd; 70 | jcur = true; 71 | 72 | end 73 | 74 | % Scale by -gamma and add identity 75 | P = - gm*P; 76 | for i = 1:mx*my 77 | P(:,:,i) = eye(2) + P(:,:,i); 78 | end 79 | 80 | flag = 0; 81 | data.P = P; 82 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/cvkx_psol.m: -------------------------------------------------------------------------------- 1 | function [z, flag, new_data] = cvkx_psol(t,y,fy,r,data) 2 | %CVKX_PSOL - Preconditioner solve function for the CVKX example problem. 3 | % 4 | % See also: cvkx, CVPrecSolveFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | P = data.P; 11 | 12 | mx = data.mx; 13 | my = data.my; 14 | 15 | r = reshape(r,2,mx*my); 16 | 17 | for i = 1:mx*my 18 | z(:,i) = P(:,:,i)^(-1)*r(:,i); 19 | end 20 | 21 | z = reshape(z,2*mx*my,1); 22 | 23 | flag = 0; 24 | new_data = []; 25 | 26 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/pleiades_J.m: -------------------------------------------------------------------------------- 1 | function [J, flag, new_data] = pleiades_J(t, y, fy, data) 2 | %PLEIADES_J - Jacobian function for the PLEIADES example problem. 3 | % 4 | % see also: pleiades, CVDenseJacFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | neq = 28; 11 | 12 | J = zeros(neq,neq); 13 | for i = 1:14 14 | J(i,14+i)=1.0; 15 | end 16 | for i = 2:7 17 | mi=i; 18 | for j = 1:i-1 19 | mj = j; 20 | rij = (y(i)-y(j))^2+(y(i+7)-y(j+7))^2; 21 | rij32 = rij^(3/2); 22 | rij52 = rij^(5/2); 23 | fjh = (1.0-3.0*(y(j)-y(i))^2/rij)/rij32; 24 | J(i+14,j) = mj*fjh; 25 | J(j+14,i) = mi*fjh; 26 | fjh = (1.0-3.0*(y(j+7)-y(i+7))^2/rij)/rij32; 27 | J(i+21,j+7) = mj*fjh; 28 | J(j+21,i+7) = mi*fjh; 29 | fjh = -3.0*(y(j)-y(i))*(y(j+7)-y(i+7))/rij52; 30 | J(i+14,j+7) = mj*fjh; 31 | J(j+14,i+7) = mi*fjh; 32 | J(i+21,j) = mj*fjh; 33 | J(j+21,i) = mi*fjh; 34 | end 35 | end 36 | for i = 1:7 37 | sumxx = 0.0; 38 | sumxy = 0.0; 39 | sumyy = 0.0; 40 | for j = 1:7 41 | if j ~= i 42 | sumxx = sumxx + J(i+14,j); 43 | sumxy = sumxy + J(i+14,j+7); 44 | sumyy = sumyy + J(i+21,j+7); 45 | end 46 | end 47 | J(i+14,i) = -sumxx; 48 | J(i+14,i+7) = -sumxy; 49 | J(i+21,i) = -sumxy; 50 | J(i+21,i+7) = -sumyy; 51 | end 52 | 53 | flag = 0; 54 | new_data = []; 55 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/pleiades_f.m: -------------------------------------------------------------------------------- 1 | function [yd, flag, new_data] = pleiades_f(t, y, data) 2 | %PLEIADES_F - RHS function for the PLEIADES example problems. 3 | % 4 | % See also: pleiades, CVRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | for i = 1:7 12 | sumx = 0.0; 13 | sumy = 0.0; 14 | for j = 1:7 15 | mj = j; 16 | rij = (y(i)-y(j))^2 + (y(i+7)-y(j+7))^2; 17 | rij32 = rij^(3/2); 18 | if j ~= i 19 | sumx = sumx + mj*(y(j)-y(i))/rij32; 20 | sumy = sumy + mj*(y(j+7)-y(i+7))/rij32; 21 | end 22 | end 23 | yd(i+14) = sumx; 24 | yd(i+21) = sumy; 25 | end 26 | for i = 1:14 27 | yd(i) = y(i+14); 28 | end 29 | 30 | flag = 0; 31 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/vdp.m: -------------------------------------------------------------------------------- 1 | %VDP - CVODES example problem (serial, dense) 2 | % This is the van der Pol Matlab example, solved with CVODES. 3 | % 4 | % See also: vdp_f, vdp_J 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.3 $Date: 2006/10/05 22:12:23 $ 9 | 10 | 11 | data.mu = 100.0; 12 | 13 | t0 = 0.0; 14 | y0 = [2.0;0.0]; 15 | 16 | options = CVodeSetOptions('RelTol',1.e-3,... 17 | 'AbsTol',1e-6,... 18 | 'JacobianFn',@vdp_J); 19 | 20 | mondata.mode = 'both'; 21 | mondata.sol = true; 22 | options = CVodeSetOptions(options,'MonitorFn',@CVodeMonitor,'MonitorData',mondata); 23 | 24 | CVodeMalloc(@vdp_f,t0,y0,options,data); 25 | 26 | % Using default options 27 | %CVodeMalloc('vdp_f',t0,y0,[],data); 28 | 29 | tout = 300.0; 30 | i = 1; 31 | while 1 32 | [status,t,y] = CVode(tout,'OneStep'); 33 | if status < 0 34 | fprintf('At t = %f status = %d\n',t,status); 35 | end 36 | tt(i) = t; 37 | yy(i) = y(1); 38 | i = i + 1; 39 | if t > tout 40 | break; 41 | end 42 | end 43 | 44 | CVodeFree; 45 | 46 | figure; 47 | plot(tt,yy); 48 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/vdp_J.m: -------------------------------------------------------------------------------- 1 | function [J, flag, new_data] = vdp_J(t, y, fy, data) 2 | %VDP_J - Jacobian funciton for the VDP example problem 3 | % 4 | % See also: vdp, CVDenseJacFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | mu = data.mu; 12 | 13 | J = [ 0 1 14 | -2*mu*y(1)*y(2)-1 mu*(1-y(1)^2) ]; 15 | 16 | flag = 0; 17 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/cvodes/examples_ser/vdp_f.m: -------------------------------------------------------------------------------- 1 | function [yd, flag, new_data] = vdp_f(t, y, data) 2 | %VDP_F - RHS function for the VDP example problem. 3 | % 4 | % See also: vdp, CVRhsFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/02/13 23:01:27 $ 9 | 10 | 11 | mu = data.mu; 12 | 13 | yd = [ y(2) 14 | mu*(1-y(1)^2)*y(2)-y(1) ]; 15 | 16 | flag = 0; 17 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/doc/sundialsTB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/WormSim/sundials-2.3.0/sundialsTB/doc/sundialsTB.pdf -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/Contents.m: -------------------------------------------------------------------------------- 1 | % IDAS, a DAE integrator with sensitivity analysis capabilities 2 | % 3 | % NOTE: 4 | % FUNCTIONS MARKED WITH * ARE NOT CURRENTLY AVAILABLE 5 | % 6 | % Functions 7 | % IDASetOptions - creates an options structure for IDAS. 8 | % IDAMalloc - allocates and initializes memory for IDAS. 9 | % * IDAMallocB - allocates and initializes backward memory for IDAS. 10 | % IDASolve - integrates the DAE 11 | % * IDASolveB - integrates the backward DAE. 12 | % IDAGetStats - returns statistics for the IDAS solver 13 | % * IDAGetStatsB - returns statistics for the backward IDAS solver 14 | % * IDAGet - extracts data from IDAS memory 15 | % IDAFree - deallocates memory for the IDAS solver. 16 | % 17 | % User-supplied function types 18 | % IDAResFn - residual function 19 | % IDARootFn - root-finding function 20 | % * IDAQuadRhsFn - quadrature RHS function 21 | % IDADenseJacFn - dense Jacobian function 22 | % IDABandJacFn - banded Jacobian function 23 | % IDAJacTimesVecFn - Jacobian times vector function 24 | % IDAPrecSetupFn - preconditioner setup function 25 | % IDAPrecSolveFn - preconditioner solve function 26 | % IDAGlocalFn - residual approximation function (BBDPre) 27 | % IDAGcomFn - communication function (BBDPre) 28 | % * IDASensResFn - sensitivity residual function 29 | % IDAMonitorFn - monitoring function 30 | % 31 | % Serial examples 32 | % idadenx - Robertson chemical kinetics example 33 | % idabanx - 1-D heat equation 34 | % 35 | % Parallel examples 36 | % N/A 37 | % 38 | % Use the mpirun function to run any of the parallel examples 39 | % 40 | % See also nvector, putils 41 | 42 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDACalcICB.m: -------------------------------------------------------------------------------- 1 | function [status, varargout] = IDACalcICB(tout,icmeth) 2 | %IDACalcICB computes consistent initial conditions for the backward phase. 3 | % 4 | % Usage: STATUS = IDACalcICB ( TOUTB, ICMETHB ) 5 | % [STATUS, YY0B, YP0B] = IDACalcIC ( TOUTB, ICMETHB ) 6 | % 7 | % See also: IDASetOptions, IDAMallocB, IDAReInitB 8 | 9 | % Radu Serban 10 | % Copyright (c) 2005, The Regents of the University of California. 11 | % $Revision: 1.1 $Date: 2006/07/19 20:52:28 $ 12 | 13 | mode = 8; 14 | 15 | if nargout == 1 16 | status = idm(mode, tout, icmeth); 17 | elseif nargout == 3 18 | [status, yy, yp] = idm(mode, tout, icmeth); 19 | varargout(1) = {yy}; 20 | varargout(2) = {yp}; 21 | else 22 | disp('IDACalcICB:: wrong number of output arguments'); 23 | end 24 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDAFree.m: -------------------------------------------------------------------------------- 1 | function [] = IDAFree() 2 | %IDAFree deallocates memory for the IDAS solver. 3 | % 4 | % Usage: IDAFree 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.1 $Date: 2006/07/17 16:49:49 $ 9 | 10 | mode = 30; 11 | idm(mode); 12 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDAGet.m: -------------------------------------------------------------------------------- 1 | function varargout = IDAGet(key, varargin) 2 | %IDAGet extracts data from the IDAS solver memory. 3 | % 4 | % Usage: RET = IDAGet ( KEY [, P1 [, P2] ... ]) 5 | % 6 | % IDAGet returns internal IDAS information based on KEY. For some values 7 | % of KEY, additional arguments may be required and/or more than one output is 8 | % returned. 9 | % 10 | % KEY is a string and should be one of: 11 | % o ErrorWeights - Returns a vector containing the current error weights. 12 | % EWT = IDAGet('ErrorWeights') 13 | % o CheckPointsInfo - Returns an array of structures with check point information. 14 | % CK = IDAGet('CheckPointInfo) 15 | % o CurrentCheckPoint - Returns the address of the active check point 16 | % ADDR = IDAGet('CurrentCheckPoint'); 17 | % o DataPointInfo - Returns information stored for interpolation at the I-th data 18 | % point in between the current check points. The index I must be passed through 19 | % the agument P1. 20 | % If the interpolation type was Hermite (see IDASetOptions), it returns two 21 | % vectors, Y and YD: 22 | % [Y, YD] = IDAGet('DataPointInfo', I) 23 | 24 | % Radu Serban 25 | % Copyright (c) 2005, The Regents of the University of California. 26 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 27 | 28 | mode = 22; 29 | 30 | if strcmp(key, 'ErrorWeights') 31 | ewt = idm(mode,2); 32 | varargout(1) = {ewt}; 33 | elseif strcmp(key, 'CheckPointsInfo') 34 | ck = idm(mode,4); 35 | varargout(1) = {ck}; 36 | elseif strcmp(key, 'CurrentCheckPoint') 37 | addr = idm(mode, 5); 38 | varargout(1) = {addr}; 39 | elseif strcmp(key, 'DataPointInfo') 40 | i = varargin{1}; 41 | varargout = idm(mode,6,i); 42 | else 43 | error('IDAGet:: Unrecognized key'); 44 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDAMalloc.m: -------------------------------------------------------------------------------- 1 | function [] = IDAMalloc(fct,t0,yy0,yp0,varargin) 2 | %IDAMalloc allocates and initializes memory for IDAS. 3 | % 4 | % Usage: IDAMalloc ( DAEFUN, T0, YY0, YP0 [, OPTIONS [, DATA] ] ) 5 | % 6 | % DAEFUN is a function defining the DAE residual: f(t,yy,yp). 7 | % This function must return a vector containing the current 8 | % value of the residual. 9 | % T0 is the initial value of t. 10 | % YY0 is the initial condition vector y(t0). 11 | % YP0 is the initial condition vector y'(t0). 12 | % OPTIONS is an (optional) set of integration options, created with 13 | % the IDASetOptions function. 14 | % DATA is (optional) problem data passed unmodified to all 15 | % user-provided functions when they are called. For example, 16 | % YD = DAEFUN(T,YY,YP,DATA). 17 | % 18 | % See also: IDARhsFn 19 | 20 | % Radu Serban 21 | % Copyright (c) 2005, The Regents of the University of California. 22 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 23 | 24 | mode = 1; 25 | 26 | if nargin < 4 27 | disp('IDAMalloc:: too few parameters'); 28 | return 29 | end 30 | 31 | options = []; 32 | data =[]; 33 | if nargin > 4 34 | options = varargin{1}; 35 | end 36 | if nargin > 5 37 | data = varargin{2}; 38 | end 39 | 40 | idm(mode,fct,t0,yy0,yp0,options,data); 41 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDAMallocB.m: -------------------------------------------------------------------------------- 1 | function [] = IDAMallocB(fctB,tB0,yyB0,ypB0,varargin) 2 | %IDAMallocB allocates and initializes backward memory for IDAS. 3 | % 4 | % Usage: IDAMallocB ( FCTB, TB0, YYB0, YPB0 [, OPTIONSB] ) 5 | % 6 | % FCTB is a function defining the adjoint DAE residual. 7 | % This function must return a vector containing the current 8 | % value of the adjoint DAE residual. 9 | % TB0 is the final value of t. 10 | % YYB0 is the final condition vector yB(tB0). 11 | % YPB0 is the final condition vector yB'(tB0). 12 | % OPTIONSB is an (optional) set of integration options, created with 13 | % the IDASetOptions function. 14 | % 15 | % See also: IDAResFn 16 | % 17 | 18 | % Radu Serban 19 | % Copyright (c) 2005, The Regents of the University of California. 20 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 21 | 22 | mode = 4; 23 | 24 | if nargin < 4 25 | disp('IDAMallocB:: too few parameters'); 26 | return 27 | end 28 | 29 | options = []; 30 | if nargin == 5 31 | optionsB = varargin{1}; 32 | end 33 | 34 | idm(mode,fctB,tB0,yyB0,ypB0,optionsB); 35 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDAResFn.m: -------------------------------------------------------------------------------- 1 | %IDAResFn - type for user provided RHS type 2 | % 3 | %IVP Problem 4 | % 5 | % The function DAEFUN must be defined as 6 | % FUNCTION [R, FLAG] = DAEFUN(T, YY, YP) 7 | % and must return a vector R corresponding to f(t,yy,yp). 8 | % If a user data structure DATA was specified in IDAMalloc, then 9 | % DAEFUN must be defined as 10 | % FUNCTION [R, FLAG, NEW_DATA] = DAEFUN(T, YY, YP, DATA) 11 | % If the local modifications to the user data structure are needed 12 | % in other user-provided functions then, besides setting the vector YD, 13 | % the DAEFUN function must also set NEW_DATA. Otherwise, it should set 14 | % NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 15 | % unnecessary copying). 16 | % 17 | % The function DAEFUN must set FLAG=0 if successful, FLAG<0 if an 18 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 19 | % occurred. 20 | % 21 | %Adjoint Problem 22 | % 23 | % The function DAEFUNB must be defined either as 24 | % FUNCTION [RB, FLAG] = DAEFUNB(T, YY, YP, YYB, YPB) 25 | % or as 26 | % FUNCTION [RB, FLAG, NEW_DATA] = DAEFUNB(T, YY, YP, YYB, YPB, DATA) 27 | % depending on whether a user data structure DATA was specified in 28 | % IDAMalloc. In either case, it must return the vector RB 29 | % corresponding to fB(t,yy,yp,yyB,ypB). 30 | % 31 | % The function DAEFUNB must set FLAG=0 if successful, FLAG<0 if an 32 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 33 | % occurred. 34 | % 35 | % See also IDAMalloc, IDAMallocB 36 | % 37 | % NOTE: DAEFUN and DAEFUNB are specified through the IDAMalloc and 38 | % IDAMallocB functions, respectively. 39 | 40 | % Radu Serban 41 | % Copyright (c) 2005, The Regents of the University of California. 42 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 43 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDARootFn.m: -------------------------------------------------------------------------------- 1 | %IDARootFn - type for user provided root-finding function. 2 | % 3 | % The function ROOTFUN must be defined as 4 | % FUNCTION [G, FLAG] = ROOTFUN(T,YY,YP) 5 | % and must return a vector G corresponding to g(t,yy,yp). 6 | % If a user data structure DATA was specified in IDAMalloc, then 7 | % ROOTFUN must be defined as 8 | % FUNCTION [G, FLAG, NEW_DATA] = ROOTFUN(T,YY,YP,DATA) 9 | % If the local modifications to the user data structure are needed in 10 | % other user-provided functions then, besides setting the vector G, 11 | % the ROOTFUN function must also set NEW_DATA. Otherwise, it should 12 | % set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 13 | % unnecessary copying). 14 | % 15 | % The function ROOTFUN must set FLAG=0 if successful, or FLAG~=0 if 16 | % a failure occurred. 17 | % 18 | % See also IDASetOptions 19 | % 20 | % NOTE: ROOTFUN is specified through the RootsFn property in 21 | % IDASetOptions and is used only if the property NumRoots is a 22 | % positive integer. 23 | 24 | % Radu Serban 25 | % Copyright (c) 2005, The Regents of the University of California. 26 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 27 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDASensMalloc.m: -------------------------------------------------------------------------------- 1 | function [] = IDASensMalloc(Ns,meth,yyS0,ypS0,varargin) 2 | %IDASensMalloc allocates and initializes memory for FSA with IDAS. 3 | % 4 | % Usage: IDASensMalloc ( NS, METH, YYS0, YPS0 [, OPTIONS ] ) 5 | % 6 | % NS is the number of parameters with respect to which sensitivities 7 | % are desired 8 | % METHOD FSA solution method [ 'Simultaneous' | {'Staggered'} ] 9 | % Specifies the FSA method for treating the nonlinear system solution for 10 | % sensitivity variables. In the simultaneous case, the nonlinear systems 11 | % for states and all sensitivities are solved simultaneously. In the 12 | % Staggered case, the nonlinear system for states is solved first and then 13 | % the nonlinear systems for all sensitivities are solved at the same time. 14 | % YYS0, YPS0 Initial conditions for sensitivity variables. 15 | % YYS0 and YPS0 must be matrices with N rows and Ns columns, where N is 16 | % the problem dimension and Ns the number of sensitivity systems. 17 | % OPTIONS is an (optional) set of FSA options, created with 18 | % the IDASetFSAOptions function. 19 | % 20 | 21 | % Radu Serban 22 | % Copyright (c) 2005, The Regents of the University of California. 23 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 24 | 25 | mode = 2; 26 | 27 | if nargin < 3 28 | disp('IDASensMalloc:: too few parameters'); 29 | return 30 | end 31 | 32 | options = []; 33 | if nargin > 3 34 | options = varargin{1}; 35 | end 36 | 37 | idm(mode,Ns,meth,yyS0,ypS0,options); 38 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDASensResFn.m: -------------------------------------------------------------------------------- 1 | %IDASensRhsFn - type for user provided sensitivity RHS function. 2 | % 3 | % The function DAESFUN must be defined as 4 | % FUNCTION [RS, FLAG] = DAESFUN(T,YY,YP,YYS,YPS) 5 | % and must return a matrix RS corresponding to fS(t,yy,yp,yyS,ypS). 6 | % If a user data structure DATA was specified in IDAMalloc, then 7 | % DAESFUN must be defined as 8 | % FUNCTION [RS, FLAG, NEW_DATA] = DAESFUN(T,YY,YP,YYS,YPS,DATA) 9 | % If the local modifications to the user data structure are needed in 10 | % other user-provided functions then, besides setting the matrix YSD, 11 | % the ODESFUN function must also set NEW_DATA. Otherwise, it should 12 | % set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 13 | % unnecessary copying). 14 | % 15 | % The function DAESFUN must set FLAG=0 if successful, FLAG<0 if an 16 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 17 | % occurred. 18 | % 19 | % See also IDASetFSAOptions 20 | % 21 | % NOTE: DAESFUN is specified through the property FSAResFn to 22 | % IDASetFSAOptions. 23 | 24 | % Radu Serban 25 | % Copyright (c) 2005, The Regents of the University of California. 26 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 27 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/IDAadjMalloc.m: -------------------------------------------------------------------------------- 1 | function [] = IDAadjMalloc(steps, interp) 2 | %IDAadjMalloc allocates and initializes memory for ASA with IDAS. 3 | % 4 | % Usage: IDAadjMalloc(STEPS, INTEPR) 5 | % 6 | % STEPS specifies the (maximum) number of integration steps between two 7 | % consecutive check points. 8 | % INTERP Specifies the type of interpolation used for estimating the forward 9 | % solution during the backward integration phase. INTERP should be 10 | % 'Hermite', indicating cubic Hermite interpolation, or 'Polynomial', 11 | % indicating variable order polynomial interpolation. 12 | 13 | % Radu Serban 14 | % Copyright (c) 2005, The Regents of the University of California. 15 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 16 | 17 | mode = 3; 18 | 19 | idm(mode,steps,interp); 20 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/examples_ser/idabanx_f.m: -------------------------------------------------------------------------------- 1 | function [rr,flag,new_data] = idabanx_f(t,yy,yp,data) 2 | 3 | m = data.m; 4 | N = data.N; 5 | dx = data.dx; 6 | c = data.c; 7 | 8 | % Initialize resval to uu, to take care of boundary equations. 9 | rr = yy; 10 | 11 | % Loop over interior points; set rr = yp - (central difference). 12 | for j = 1:m-2 13 | offset = m*j; 14 | for i = 1:m-2 15 | loc = offset + i + 1; 16 | rr(loc) = yp(loc) - c * ... 17 | (yy(loc-1) + yy(loc+1) + yy(loc-m) + yy(loc+m) - 4.0*yy(loc)); 18 | end 19 | end 20 | 21 | flag = 0; 22 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/examples_ser/idabanx_ic.m: -------------------------------------------------------------------------------- 1 | function [t,yy,yp,id,cnstr] = idabanx_ic(data) 2 | 3 | m = data.m; 4 | N = data.N; 5 | dx = data.dx; 6 | 7 | id = ones(N,1); 8 | cnstr = ones(N,1); 9 | yy = zeros(N,1); 10 | yp = zeros(N,1); 11 | 12 | t = 0.0; 13 | 14 | % Initialize yy on all grid points. */ 15 | for j=0:m-1 16 | yfact = dx * j; 17 | offset = m*j; 18 | for i=0:m-1 19 | xfact = dx * i; 20 | loc = offset + i + 1; 21 | yy(loc) = 16.0 * xfact * (1.0 - xfact) * yfact * (1.0 - yfact); 22 | end 23 | end 24 | 25 | % The residual gives the negative of ODE RHS values at 26 | % interior points. 27 | yp = zeros(N,1); 28 | [yp,flag,new_data] = idabanx_f(t,yy,yp,data); 29 | yp = -yp; 30 | 31 | % Finally, set values of yy, yp, and id at boundary points. 32 | for j=0:m-1 33 | offset = m*j; 34 | for i=0:m-1 35 | loc = offset + i + 1; 36 | if (j == 0 || j == m-1 || i == 0 || i == m-1 ) 37 | yy(loc) = 0.1; 38 | yp(loc) = 0.0; 39 | id(loc) = 0.0; 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/examples_ser/idadenx.m: -------------------------------------------------------------------------------- 1 | %IDADENX - IDAS example problem (serial, dense) 2 | % 3 | % See also: idadenx_f, idadenx_g, idadenx_J 4 | 5 | % Radu Serban 6 | % Copyright (c) 2005, The Regents of the University of California. 7 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 8 | 9 | data.p = [0.04; 1.0e4; 3.0e7]; 10 | 11 | t0 = 0.0; 12 | y0 = [1.0;0.0;0.0]; 13 | yp0 = [-0.04;0.04;0.0]; 14 | 15 | options = IDASetOptions('RelTol',1.e-4,... 16 | 'AbsTol',[1.e-8; 1.e-14; 1.e-6],... 17 | 'LinearSolver','Dense',... 18 | 'JacobianFn',@idadenx_J); 19 | 20 | options = IDASetOptions(options,'RootsFn',@idadenx_g, 'NumRoots',2); 21 | 22 | mondata.sol = true; 23 | mondata.update = 100; 24 | options = IDASetOptions(options,'MonitorFn',@IDAMonitor,'MonitorData',mondata); 25 | 26 | IDAMalloc(@idadenx_f,t0,y0,yp0,options,data); 27 | 28 | t1 = 0.4; 29 | tmult = 10.0; 30 | nout = 12; 31 | 32 | fprintf('-----------------------------------------------------------------------\n'); 33 | fprintf(' t y1 y2 y3'); 34 | fprintf(' | nst k h\n'); 35 | fprintf('-----------------------------------------------------------------------\n'); 36 | 37 | iout = 0; 38 | tout = t1; 39 | while iout < nout 40 | 41 | [status,t,y,yp] = IDASolve(tout,'Normal'); 42 | 43 | % Extract statistics 44 | si = IDAGetStats; 45 | 46 | % Print output 47 | if(status == 2) 48 | fprintf(' ... Root found %d %d\n',si.RootInfo.roots(1), si.RootInfo.roots(2)); 49 | end 50 | fprintf('%10.4e %12.4e %12.4e %12.4e | %3d %1d %12.4e\n',... 51 | t, y(1), y(2), y(3), si.nst, si.qlast, si.hlast); 52 | 53 | % Update output time 54 | if(status == 0) 55 | iout = iout+1; 56 | tout = tout*tmult; 57 | end 58 | 59 | end 60 | 61 | si = IDAGetStats; 62 | 63 | IDAFree; 64 | 65 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/examples_ser/idadenx_J.m: -------------------------------------------------------------------------------- 1 | function [J, flag, new_data] = idadenx_J(t, y, yp, rr, cj, data) 2 | %IDADENX_J - Jacobian function for the IDADENX example problems. 3 | % 4 | % see also: idadenx, IDADenseJacFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 9 | 10 | 11 | r1 = data.p(1); 12 | r2 = data.p(2); 13 | r3 = data.p(3); 14 | 15 | J(1,1) = -r1 - cj; 16 | J(2,1) = r1; 17 | J(3,1) = 1.0; 18 | 19 | J(1,2) = r2*y(3); 20 | J(2,2) = -r2*y(3) - 2*r3*y(2) - cj; 21 | J(3,2) = 1.0; 22 | 23 | J(1,3) = r2*y(2); 24 | J(2,3) = -r2*y(2); 25 | J(3,3) = 1.0; 26 | 27 | flag = 0; 28 | new_data = []; 29 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/examples_ser/idadenx_f.m: -------------------------------------------------------------------------------- 1 | function [rr, flag, new_data] = idadenx_f(t, y, yp, data) 2 | %IDADENX_F - Residual function for the IDADENX example problems. 3 | % 4 | % See also: idadenx, IDAResFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 9 | 10 | 11 | r1 = data.p(1); 12 | r2 = data.p(2); 13 | r3 = data.p(3); 14 | 15 | rr(1) = -r1*y(1) + r2*y(2)*y(3) - yp(1); 16 | rr(2) = r1*y(1) - r2*y(2)*y(3) - r3*y(2)*y(2) - yp(2); 17 | rr(3) = y(1) + y(2) + y(3) - 1.0; 18 | 19 | flag = 0; 20 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/examples_ser/idadenx_g.m: -------------------------------------------------------------------------------- 1 | function [g, flag, new_data] = idadenx_g(t,y,yp,data) 2 | %IDADENX_G - Root-finding function for the IDADENX example problem. 3 | % 4 | % See also: idadenx, IDARootFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $ 9 | 10 | 11 | g(1) = y(1) - 0.0001; 12 | g(2) = y(3) - 0.01; 13 | 14 | flag = 0; 15 | new_data = []; 16 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/Contents.m: -------------------------------------------------------------------------------- 1 | % MEX binding of IDAS functions 2 | % 3 | %-- Radu Serban @ LLNL -- April 2005 4 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_bjac.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = idm_bjac(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | yy = varargin{2}; 15 | yp = varargin{3}; 16 | rr = varargin{4}; 17 | cj = varargin{5}; 18 | fct = varargin{6}; 19 | data = varargin{7}; 20 | 21 | if isempty(data) 22 | [ret, flag] = feval(fct,t,yy,yp,rr,cj); 23 | new_data = []; 24 | else 25 | [ret, flag, new_data] = feval(fct,t,yy,yp,rr,cj,data); 26 | end 27 | 28 | case -1 29 | 30 | % Backward ODE 31 | 32 | t = varargin{1}; 33 | yy = varargin{2}; 34 | yp = varargin{3}; 35 | yyB = varargin{4}; 36 | ypB = varargin{5}; 37 | rrB = varargin{6}; 38 | cjB = varargin{7}; 39 | fct = varargin{8}; 40 | data = varargin{9}; 41 | 42 | if isempty(data) 43 | [ret, flag] = feval(fct,t,yy,yp,yyB,ypB,rrB,cjB); 44 | new_data = []; 45 | else 46 | [ret, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,rrB,cjB,data); 47 | end 48 | 49 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_djac.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = idm_djac(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | yy = varargin{2}; 15 | yp = varargin{3}; 16 | rr = varargin{4}; 17 | cj = varargin{5}; 18 | fct = varargin{6}; 19 | data = varargin{7}; 20 | 21 | if isempty(data) 22 | [ret, flag] = feval(fct,t,yy,yp,rr,cj); 23 | new_data = []; 24 | else 25 | [ret, flag, new_data] = feval(fct,t,yy,yp,rr,cj,data); 26 | end 27 | 28 | case -1 29 | 30 | % Backward ODE 31 | 32 | t = varargin{1}; 33 | yy = varargin{2}; 34 | yp = varargin{3}; 35 | yyB = varargin{4}; 36 | ypB = varargin{5}; 37 | rrB = varargin{6}; 38 | cjB = varargin{7}; 39 | fct = varargin{8}; 40 | data = varargin{9}; 41 | 42 | if isempty(data) 43 | [ret, flag] = feval(fct,t,yy,yp,yyB,ypB,rrB,cjB); 44 | new_data = []; 45 | else 46 | [ret, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,rrB,cjB,data); 47 | end 48 | 49 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_gcom.m: -------------------------------------------------------------------------------- 1 | function [flag, new_data] = idm_gcom(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | yy = varargin{2}; 15 | yp = varargin{3}; 16 | fct = varargin{4}; 17 | data = varargin{5}; 18 | 19 | if isempty(data) 20 | flag = feval(fct,t,yy,yp); 21 | new_data = []; 22 | else 23 | [flag, new_data] = feval(fct,t,yy,yp,data); 24 | end 25 | 26 | case -1 27 | 28 | % Backward ODE 29 | 30 | t = varargin{1}; 31 | yy = varargin{2}; 32 | yp = varargin{3}; 33 | yyB = varargin{4}; 34 | ypB = varargin{5}; 35 | fct = varargin{6}; 36 | data = varargin{7}; 37 | 38 | if isempty(data) 39 | flag = feval(fct,t,yy,yp,yyB,ypB); 40 | new_data = []; 41 | else 42 | [flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,data); 43 | end 44 | 45 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_gloc.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = idm_gloc(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | yy = varargin{2}; 15 | yp = varargin{3}; 16 | fct = varargin{4}; 17 | data = varargin{5}; 18 | 19 | if isempty(data) 20 | [ret, flag] = feval(fct,t,yy,yp); 21 | new_data = []; 22 | else 23 | [ret, flag, new_data] = feval(fct,t,yy,yp,data); 24 | end 25 | 26 | case -1 27 | 28 | % Backward ODE 29 | 30 | t = varargin{1}; 31 | yy = varargin{2}; 32 | yp = varargin{3}; 33 | yyB = varargin{4}; 34 | ypB = varargin{5}; 35 | fct = varargin{6}; 36 | data = varargin{7}; 37 | 38 | if isempty(data) 39 | [ret, flag] = feval(fct,t,yy,yp,yyB,ypB); 40 | new_data = []; 41 | else 42 | [ret, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,data); 43 | end 44 | 45 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_jtv.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = idm_jtv(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | yy = varargin{2}; 15 | yp = varargin{3}; 16 | rr = varargin{4}; 17 | v = varargin{5}; 18 | cj = varargin{6}; 19 | fct = varargin{7}; 20 | data = varargin{8}; 21 | 22 | if isempty(data) 23 | [ret, flag] = feval(fct,t,yy,yp,rr,v,cj); 24 | new_data = []; 25 | else 26 | [ret, flag, new_data] = feval(fct,t,yy,yp,rr,v,cj,data); 27 | end 28 | 29 | case -1 30 | 31 | % Backward ODE 32 | 33 | t = varargin{1}; 34 | yy = varargin{2}; 35 | yp = varargin{3}; 36 | yyB = varargin{4}; 37 | ypB = varargin{5}; 38 | rrB = varargin{6}; 39 | vB = varargin{7}; 40 | cjB = varargin{8}; 41 | fct = varargin{9}; 42 | data = varargin{10}; 43 | 44 | if isempty(data) 45 | [ret, flag] = feval(fct,t,yy,yp,yyB,ypB,rrB,vB,cjB); 46 | new_data =[]; 47 | else 48 | [ret, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,rrB,vB,cjB,data); 49 | end 50 | 51 | 52 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_monitor.m: -------------------------------------------------------------------------------- 1 | function [new_mondata] = idm_monitor(call, t, yy, yp, yQ, Ns, yyS, ypS, fct, mondata) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | N = length(yy); 8 | yyS = reshape(yyS, N, Ns); 9 | ypS = reshape(ypS, N, Ns); 10 | 11 | if isempty(mondata) 12 | feval(fct, call, t, yy, yp, yQ, yyS, ypS); 13 | new_mondata = []; 14 | else 15 | new_mondata = feval(fct, call, t, yy, yp, yQ, yyS, ypS, mondata); 16 | end 17 | 18 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_pset.m: -------------------------------------------------------------------------------- 1 | function [flag, new_data] = idm_pset(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | yy = varargin{2}; 15 | yp = varargin{3}; 16 | rr = varargin{4}; 17 | cj = varargin{5}; 18 | fct = varargin{6}; 19 | data = varargin{7}; 20 | 21 | if isempty(data) 22 | [flag] = feval(fct,t,yy,yp,rr,cj); 23 | new_data = []; 24 | else 25 | [flag, new_data] = feval(fct,t,yy,yp,rr,cj,data); 26 | end 27 | 28 | case -1 29 | 30 | % Backward ODE 31 | 32 | t = varargin{1}; 33 | yy = varargin{2}; 34 | yp = varargin{3}; 35 | yyB = varargin{4}; 36 | ypB = varargin{5}; 37 | rrB = varargin{6}; 38 | cjB = varargin{7}; 39 | fct = varargin{8}; 40 | data = varargin{9}; 41 | 42 | if isempty(data) 43 | [flag] = feval(fct,t,yy,yp,yyB,ypB,rrB,cjB); 44 | new_data = []; 45 | else 46 | [flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,rrB,cjB,data); 47 | end 48 | 49 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_psol.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = idm_psol(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | yy = varargin{2}; 15 | yp = varargin{3}; 16 | rr = varargin{4}; 17 | r = varargin{5}; 18 | cj = varargin{6}; 19 | fct = varargin{7}; 20 | data = varargin{8}; 21 | 22 | if isempty(data) 23 | [ret, flag] = feval(fct,t,yy,yp,rr,r,cj); 24 | new_data = []; 25 | else 26 | [ret, flag, new_data] = feval(fct,t,yy,yp,rr,r,cj,data); 27 | end 28 | 29 | case -1 30 | 31 | % Backward ODE 32 | 33 | t = varargin{1}; 34 | yy = varargin{2}; 35 | yp = varargin{3}; 36 | yyB = varargin{4}; 37 | ypB = varargin{5}; 38 | rrB = varargin{6}; 39 | rB = varargin{7}; 40 | cjB = varargin{8}; 41 | fct = varargin{9}; 42 | data = varargin{10}; 43 | 44 | if isempty(data) 45 | [ret, flag] = feval(fct,t,yy,yp,yyB,ypB,rrB,rB,cjB); 46 | new_data = []; 47 | else 48 | [ret, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,rrB,rB,cjB,data); 49 | end 50 | 51 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_res.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = idm_res(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | yy = varargin{2}; 15 | yp = varargin{3}; 16 | fct = varargin{4}; 17 | data = varargin{5}; 18 | 19 | if isempty(data) 20 | [ret, flag] = feval(fct,t,yy,yp); 21 | new_data = []; 22 | else 23 | [ret, flag, new_data] = feval(fct,t,yy,yp,data); 24 | end 25 | 26 | case -1 27 | 28 | % Backward ODE 29 | 30 | t = varargin{1}; 31 | yy = varargin{2}; 32 | yp = varargin{3}; 33 | yyB = varargin{4}; 34 | ypB = varargin{5}; 35 | fct = varargin{6}; 36 | data = varargin{7}; 37 | 38 | if isempty(data) 39 | [ret, flag] = feval(fct,t,yy,yp,yyB,ypB); 40 | new_data = []; 41 | else 42 | [ret, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,data); 43 | end 44 | 45 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_resS.m: -------------------------------------------------------------------------------- 1 | function [rrS, flag, new_data] = idm_resS(t, yy, yp, rr, Ns, yyS, ypS, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | N = length(y); 8 | yyS = reshape(yyS, N, Ns); 9 | ypS = reshape(ypS, N, Ns); 10 | 11 | if isempty(data) 12 | [rrS, flag] = feval(fct,t,yy,yp,rr,yyS,ypS); 13 | new_data = []; 14 | else 15 | [rrS, flag, new_data] = feval(fct,t,yy,yp,rr,yyS,ypS,data); 16 | end 17 | 18 | rrS = reshape(rrS, N*Ns, 1); -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_rhsQ.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = idm_rhsQ(type, varargin) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | switch type 8 | 9 | case 1 10 | 11 | % Forward ODE 12 | 13 | t = varargin{1}; 14 | yy = varargin{2}; 15 | yp = varargin{3}; 16 | fct = varargin{4}; 17 | data = varargin{5}; 18 | 19 | if isempty(data) 20 | [ret, flag] = feval(fct,t,yy,yp); 21 | new_data =[]; 22 | else 23 | [ret, flag, new_data] = feval(fct,t,yy,yp,data); 24 | end 25 | 26 | case -1 27 | 28 | % Backward ODE 29 | 30 | t = varargin{1}; 31 | yy = varargin{2}; 32 | yp = varargin{3}; 33 | yyB = varargin{4}; 34 | ypB = varargin{5}; 35 | fct = varargin{6}; 36 | data = varargin{7}; 37 | 38 | if isempty(data) 39 | [ret, flag] = feval(fct,t,yy,yp,yyB,ypB); 40 | new_data = []; 41 | else 42 | [ret, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,data); 43 | end 44 | 45 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/idas/idm/idm_root.m: -------------------------------------------------------------------------------- 1 | function [g, flag, new_data] = idm_root(t, yy, yp, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | if isempty(data) 8 | [g, flag] = feval(fct,t,yy,yp); 9 | new_data = []; 10 | else 11 | [g, flag, new_data] = feval(fct,t,yy,yp,data); 12 | end 13 | 14 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/Contents.m: -------------------------------------------------------------------------------- 1 | % KINSOL, nonlinear system solver 2 | % 3 | % Functions 4 | % KINSetOptions - creates an options structure for KINSOL. 5 | % KINMalloc - allocates and initializes memory for KINSOL. 6 | % KINSol - solves the nonlinear problem. 7 | % KINGetStats - returns statistics for the KINSOL solver 8 | % KINFree - deallocates memory for the KINSOL solver. 9 | % 10 | % User-supplied function types 11 | % KINsysFn - system function 12 | % KINDenseJacFn - dense Jacobian function 13 | % KINJacTimesVecFn - Jacobian times vector function 14 | % KINPrecSetupFn - preconditioner setup function 15 | % KINPrecSolveFn - preconditioner solve function 16 | % KINGlocalFn - RHS approximation function (BBDPre) 17 | % KINGcomFn - communication function (BBDPre) 18 | % 19 | % Serial examples 20 | % kindiag - simple serial diagonal example 21 | % kindx - simple 2 dimensional example 22 | % 23 | % Parallel examples 24 | % kindiagp - simple parallel diagonal example 25 | % Use the mpirun function to run any of the parallel examples 26 | % 27 | % See also nvector, putils 28 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINBandJacFn.m: -------------------------------------------------------------------------------- 1 | %KINBandJacFn - type for user provided banded Jacobian function. 2 | % 3 | % The function BJACFUN must be defined as 4 | % FUNCTION [J, FLAG] = BJACFUN(Y, FY) 5 | % and must return a matrix J corresponding to the banded Jacobian of f(y). 6 | % The input argument FY contains the current value of f(y). 7 | % If a user data structure DATA was specified in KINMalloc, then 8 | % BJACFUN must be defined as 9 | % FUNCTION [J, FLAG, NEW_DATA] = BJACFUN(Y, FY, DATA) 10 | % If the local modifications to the user data structure are needed in 11 | % other user-provided functions then, besides setting the matrix J and 12 | % the flag FLAG, the BJACFUN function must also set NEW_DATA. Otherwise, 13 | % it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead 14 | % to unnecessary copying). 15 | % 16 | % The function BJACFUN must set FLAG=0 if successful, FLAG<0 if an 17 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 18 | % occurred. 19 | % 20 | % See also KINSetOptions 21 | % 22 | % NOTE: BJACFUN is specified through the property JacobianFn to KINSetOptions 23 | % and is used only if the property LinearSolver was set to 'Band'. 24 | 25 | % Radu Serban 26 | % Copyright (c) 2005, The Regents of the University of California. 27 | % $Revision: 1.1 $Date: 2006/03/15 19:31:27 $ 28 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINDenseJacFn.m: -------------------------------------------------------------------------------- 1 | %KINDenseJacFn - type for user provided dense Jacobian function. 2 | % 3 | % The function DJACFUN must be defined as 4 | % FUNCTION [J, FLAG] = DJACFUN(Y,FY) 5 | % and must return a matrix J corresponding to the Jacobian of f(y). 6 | % The input argument FY contains the current value of f(y). 7 | % If a user data structure DATA was specified in KINMalloc, then 8 | % DJACFUN must be defined as 9 | % FUNCTION [J, FLAG, NEW_DATA] = DJACFUN(Y,FY,DATA) 10 | % If the local modifications to the user data structure are needed in 11 | % other user-provided functions then, besides setting the matrix J and 12 | % the flag FLAG, the DJACFUN function must also set NEW_DATA. Otherwise, 13 | % it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead 14 | % to unnecessary copying). 15 | % 16 | % The function DJACFUN must set FLAG=0 if successful, FLAG<0 if an 17 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 18 | % occurred. 19 | % 20 | % See also KINSetOptions 21 | % 22 | % NOTE: DJACFUN is specified through the property JacobianFn to KINSetOptions 23 | % and is used only if the property LinearSolver was set to 'Dense'. 24 | 25 | % Radu Serban 26 | % Copyright (c) 2005, The Regents of the University of California. 27 | % $Revision: 1.2 $Date: 2006/03/15 19:31:27 $ 28 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINFree.m: -------------------------------------------------------------------------------- 1 | function [] = KINFree() 2 | %KINFree deallocates memory for the KINSOL solver. 3 | % 4 | % Usage: KINFree 5 | % 6 | 7 | % Radu Serban 8 | % Copyright (c) 2005, The Regents of the University of California. 9 | % $Revision: 1.1 $Date: 2006/01/06 19:00:02 $ 10 | 11 | mode = 6; 12 | kim(mode); 13 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINGcommFn.m: -------------------------------------------------------------------------------- 1 | %KINGcommFn - type for user provided communication function (BBDPre). 2 | % 3 | % The function GCOMFUN must be defined as 4 | % FUNCTION FLAG = GCOMFUN(Y) 5 | % and can be used to perform all interprocess communication necessary 6 | % to evaluate the approximate right-hand side function for the BBDPre 7 | % preconditioner module. 8 | % If a user data structure DATA was specified in KINMalloc, then 9 | % GCOMFUN must be defined as 10 | % FUNCTION [FLAG, NEW_DATA] = GCOMFUN(Y, DATA) 11 | % If the local modifications to the user data structure are needed 12 | % in other user-provided functions then the GCOMFUN function must also 13 | % set NEW_DATA. Otherwise, it should set NEW_DATA=[] (do not set 14 | % NEW_DATA = DATA as it would lead to unnecessary copying). 15 | % 16 | % The function GCOMFUN must set FLAG=0 if successful, FLAG<0 if an 17 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 18 | % occurred. 19 | % 20 | % See also KINGlocalFn, KINSetOptions 21 | % 22 | % NOTES: 23 | % GCOMFUN is specified through the GcommFn property in KINSetOptions 24 | % and is used only if the property PrecModule is set to 'BBDPre'. 25 | % 26 | % Each call to GCOMFUN is preceded by a call to the system function 27 | % SYSFUN with the same argument Y. Thus GCOMFUN can omit any communication 28 | % done by SYSFUN if relevant to the evaluation of G by GLOCFUN. If all 29 | % necessary communication was done by SYSFUN, GCOMFUN need not be provided. 30 | 31 | % Radu Serban 32 | % Copyright (c) 2005, The Regents of the University of California. 33 | % $Revision: 1.2 $Date: 2006/03/15 19:31:28 $ 34 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINGetStats.m: -------------------------------------------------------------------------------- 1 | function si = KINGetStats() 2 | %KINGetStats returns statistics for the main KINSOL solver and the linear 3 | %solver used. 4 | % 5 | % Usage: solver_stats = KINGetStats; 6 | % 7 | %Fields in the structure solver_stats 8 | % 9 | %o nfe - total number evaluations of the nonlinear system function SYSFUN 10 | %o nni - total number of nonlinear iterations 11 | %o nbcf - total number of beta-condition failures 12 | %o nbops - total number of backtrack operations (step length adjustments) 13 | % performed by the line search algorithm 14 | %o fnorm - scaled norm of the nonlinear system function f(y) evaluated at the 15 | % current iterate: ||fscale*f(y)||_L2 16 | %o step - scaled norm (or length) of the step used during the previous 17 | % iteration: ||uscale*p||_L2 18 | %o LSInfo - structure with linear solver statistics 19 | % 20 | %The structure LSinfo has different fields, depending on the linear solver used. 21 | % 22 | % Fields in LSinfo for the 'Dense' linear solver 23 | % 24 | %o name - 'Dense' 25 | %o njeD - number of Jacobian evaluations 26 | %o nfeD - number of right-hand side function evaluations for difference-quotient 27 | % Jacobian approximation 28 | % 29 | % Fields in LSinfo for the 'GMRES' or 'BiCGStab' linear solver 30 | % 31 | %o name - 'GMRES' or 'BiCGStab' 32 | %o nli - number of linear solver iterations 33 | %o npe - number of preconditioner setups 34 | %o nps - number of preconditioner solve function calls 35 | %o ncfl - number of linear system convergence test failures 36 | % 37 | 38 | % Radu Serban 39 | % Copyright (c) 2005, The Regents of the University of California. 40 | % $Revision: 1.1 $Date: 2006/01/06 19:00:02 $ 41 | 42 | 43 | mode = 3; 44 | si = kim(mode); 45 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINGlocalFn.m: -------------------------------------------------------------------------------- 1 | %KINGlocalFn - type for user provided RHS approximation function (BBDPre). 2 | % 3 | % The function GLOCFUN must be defined as 4 | % FUNCTION [G, FLAG] = GLOCFUN(Y) 5 | % and must return a vector G corresponding to an approximation to f(y) 6 | % which will be used in the BBDPRE preconditioner module. The case where 7 | % G is mathematically identical to F is allowed. 8 | % If a user data structure DATA was specified in KINMalloc, then 9 | % GLOCFUN must be defined as 10 | % FUNCTION [G, FLAG, NEW_DATA] = GLOCFUN(Y, DATA) 11 | % If the local modifications to the user data structure are needed 12 | % in other user-provided functions then, besides setting the vector G, 13 | % the GLOCFUN function must also set NEW_DATA. Otherwise, it should set 14 | % NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 15 | % unnecessary copying). 16 | % 17 | % The function GLOCFUN must set FLAG=0 if successful, FLAG<0 if an 18 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 19 | % occurred. 20 | % 21 | % See also KINGcommFn, KINSetOptions 22 | % 23 | % NOTE: GLOCFUN is specified through the GlocalFn property in KINSetOptions 24 | % and is used only if the property PrecModule is set to 'BBDPre'. 25 | 26 | % Radu Serban 27 | % Copyright (c) 2005, The Regents of the University of California. 28 | % $Revision: 1.2 $Date: 2006/03/15 19:31:28 $ 29 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINJacTimesVecFn.m: -------------------------------------------------------------------------------- 1 | %KINJacTimesVecFn - type for user provided Jacobian times vector function. 2 | % 3 | % The function JTVFUN must be defined as 4 | % FUNCTION [JV, NEW_Y, FLAG] = JTVFUN(Y, V, NEW_Y) 5 | % and must return a vector JV corresponding to the product of the 6 | % Jacobian of f(y) with the vector v. On input, NEW_Y indicates if 7 | % the iterate has been updated in the interim. JV must be update 8 | % or reevaluated, if appropriate, unless NEW_Y=false. This flag must 9 | % be reset by the user. 10 | % If a user data structure DATA was specified in KINMalloc, then 11 | % JTVFUN must be defined as 12 | % FUNCTION [JV, NEW_Y, FLAG, NEW_DATA] = JTVFUN(Y, V, NEW_Y, DATA) 13 | % If the local modifications to the user data structure are needed in 14 | % other user-provided functions then, besides setting the vector JV, and 15 | % flags NEW_Y and FLAG, the JTVFUN function must also set NEW_DATA. Otherwise, 16 | % it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 17 | % unnecessary copying). 18 | % 19 | % If successful, FLAG should be set to 0. If an error occurs, FLAG should 20 | % be set to a nonzero value. 21 | % 22 | % See also KINSetOptions 23 | % 24 | % NOTE: JTVFUN is specified through the property JacobianFn to KINSetOptions 25 | % and is used only if the property LinearSolver was set to 'GMRES' or 'BiCGStab'. 26 | 27 | % Radu Serban 28 | % Copyright (c) 2005, The Regents of the University of California. 29 | % $Revision: 1.2 $Date: 2006/03/15 19:31:28 $ 30 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINMalloc.m: -------------------------------------------------------------------------------- 1 | function [] = KINMalloc(fct,n,varargin) 2 | %KINMalloc allocates and initializes memory for KINSOL. 3 | % 4 | % Usage: KINMalloc ( SYSFUN, N [, OPTIONS [, DATA] ] ); 5 | % 6 | % SYSFUN is a function defining the nonlinear problem f(y) = 0. 7 | % This function must return a column vector FY containing the 8 | % current value of the residual 9 | % N is the (local) problem dimension. 10 | % OPTIONS is an (optional) set of integration options, created with 11 | % the KINSetOptions function. 12 | % DATA is the (optional) problem data passed unmodified to all 13 | % user-provided functions when they are called. For example, 14 | % RES = SYSFUN(Y,DATA). 15 | % 16 | % See also: KINSysFn 17 | 18 | % Radu Serban 19 | % Copyright (c) 2005, The Regents of the University of California. 20 | % $Revision: 1.1 $Date: 2006/01/06 19:00:02 $ 21 | 22 | mode = 1; 23 | 24 | if nargin < 2 25 | disp('KINMalloc:: too few parameters'); 26 | return 27 | end 28 | 29 | options = []; 30 | data =[]; 31 | if nargin > 2 32 | options = varargin{1}; 33 | end 34 | if nargin > 3 35 | data = varargin{2}; 36 | end 37 | 38 | kim(mode,fct,n,options,data); 39 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINPrecSolveFn.m: -------------------------------------------------------------------------------- 1 | %KINPrecSolveFn - type for user provided preconditioner solve function. 2 | % 3 | % The user-supplied preconditioner solve function PSOLFN 4 | % is to solve a linear system P z = r in which the matrix P is 5 | % the preconditioner matrix (possibly set implicitely by PSETFUN) 6 | % 7 | % The function PSOLFUN must be defined as 8 | % FUNCTION [Z, FLAG] = PSOLFUN(Y, YSCALE, FY, FSCALE, R) 9 | % and must return a vector Z containing the solution of Pz=r. 10 | % The input argument FY contains the current value of f(y), while YSCALE 11 | % and FSCALE are the scaling vectors for solution and system function, 12 | % respectively (as passed to KINSol) 13 | % 14 | % If a user data structure DATA was specified in KINMalloc, then 15 | % PSOLFUN must be defined as 16 | % FUNCTION [Z, FLAG, NEW_DATA] = PSOLFUN(Y,YSCALE,FY,FSCALE,R,DATA) 17 | % If the local modifications to the user data structure are needed in 18 | % other user-provided functions then, besides setting the vector Z and 19 | % the flag FLAG, the PSOLFUN function must also set NEW_DATA. Otherwise, 20 | % it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would 21 | % lead to unnecessary copying). 22 | % 23 | % If successful, PSOLFUN must return FLAG=0. For a recoverable error it 24 | % must set FLAG to a positive value (in which case the solver will attempt 25 | % to correct). If an unrecoverable error occurs, it must set FLAG 26 | % to a negative value, in which case the solver will halt. 27 | % 28 | % See also KINPrecSetupFn, KINSetOptions 29 | % 30 | % NOTE: PSOLFUN is specified through the property PrecSolveFn to KINSetOptions 31 | % and is used only if the property LinearSolver was set to 'GMRES' or 'BiCGStab'. 32 | 33 | % Radu Serban 34 | % Copyright (c) 2005, The Regents of the University of California. 35 | % $Revision: 1.2 $Date: 2006/03/15 19:31:28 $ 36 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/KINSysFn.m: -------------------------------------------------------------------------------- 1 | %KINSysFn - type for user provided system function 2 | % 3 | % The function SYSFUN must be defined as 4 | % FUNCTION [FY, FLAG] = SYSFUN(Y) 5 | % and must return a vector FY corresponding to f(y). 6 | % If a user data structure DATA was specified in KINMalloc, then 7 | % SYSFUN must be defined as 8 | % FUNCTION [FY, FLAG, NEW_DATA] = SYSFUN(Y,DATA) 9 | % If the local modifications to the user data structure are needed 10 | % in other user-provided functions then, besides setting the vector FY, 11 | % the SYSFUN function must also set NEW_DATA. Otherwise, it should set 12 | % NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 13 | % unnecessary copying). 14 | % 15 | % The function SYSFUN must set FLAG=0 if successful, FLAG<0 if an 16 | % unrecoverable failure occurred, or FLAG>0 if a recoverable error 17 | % occurred. 18 | % 19 | % See also KINMalloc 20 | % 21 | % NOTE: SYSFUN is specified through the KINMalloc function. 22 | 23 | % Radu Serban 24 | % Copyright (c) 2005, The Regents of the University of California. 25 | % $Revision: 1.2 $Date: 2006/03/15 19:31:28 $ 26 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/examples_par/kindiagp_pset.m: -------------------------------------------------------------------------------- 1 | function [status, new_data] = kindiagp_pset(y,yscale,fy,fscale,data) 2 | %KINDIAGP_PSET - Preconditioner setup function for the KINDIAGP example. 3 | % 4 | % See also: kindiagp, KINPrecSetupFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.1 $Date: 2006/01/06 19:00:04 $ 9 | 10 | nlocal = data.nlocal; 11 | 12 | for i = 1:nlocal 13 | P(i) = 0.5 / (y(i)+5.0); 14 | end 15 | 16 | new_data = data; 17 | new_data.P = P; 18 | 19 | status = 0; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/examples_par/kindiagp_psol.m: -------------------------------------------------------------------------------- 1 | function [x, status, new_data] = kindiagp_psol(y,yscale,fy,fscale,v,data) 2 | %KINDIAGP_PSOL - Preconditioner solve function for the KINDIAGP example. 3 | % 4 | % See also: kindiagp, KINPrecSolveFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.1 $Date: 2006/01/06 19:00:04 $ 9 | 10 | nlocal = data.nlocal; 11 | P = data.P; 12 | 13 | for i=1:nlocal 14 | x(i) = v(i) * P(i); 15 | end 16 | 17 | status = 0; 18 | new_data = []; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/examples_par/kindiagp_sys.m: -------------------------------------------------------------------------------- 1 | function [fy, flag, new_data] = kindiagp_sys(y, data) 2 | %KINDIAGP_SYS - System function for the KINDIAGP example problem. 3 | % 4 | % See also: kindiagp, KINsysFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/03/15 19:31:29 $ 9 | 10 | nlocal = data.nlocal; 11 | mype = data.mype; 12 | baseadd = mype * nlocal; 13 | 14 | for i = 1:nlocal 15 | fy(i) = y(i)^2 - (i+baseadd)^2; 16 | end 17 | 18 | flag = 0; % success 19 | new_data = []; % data was not modified -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/examples_ser/kindiag.m: -------------------------------------------------------------------------------- 1 | %KINDIAG - KINSOL example problem (serial, GMRES) 2 | % Simple diagonal test, using user-supplied preconditioner setup and 3 | % solve routines. 4 | % 5 | % This example does a basic test of the solver by solving the system: 6 | % f(y) = 0 for 7 | % f(y) = y(i)^2 - i^2 8 | % 9 | % No scaling is done. 10 | % An approximate diagonal preconditioner is used. 11 | % 12 | % See also: kindiag_sys kindag_pset kindiag_psol 13 | 14 | % Radu Serban 15 | % Copyright (c) 2005, The Regents of the University of California. 16 | % $Revision: 1.2 $Date: 2006/02/02 00:39:00 $ 17 | 18 | neq = 128; 19 | 20 | strategy = 'None'; 21 | 22 | fnormtol = 1.0e-5; 23 | scsteptol = 1.0e-4; 24 | maxl = 10; 25 | maxrs = 2; 26 | msbset = 5; 27 | 28 | options = KINSetOptions('Verbose',true,... 29 | 'FuncNormTol', fnormtol,... 30 | 'ScaledStepTol',scsteptol,... 31 | 'LinearSolver','GMRES',.... 32 | 'KrylovMaxDim', maxl,... 33 | 'MaxNumRestarts', maxrs,... 34 | 'MaxNumSetups', msbset,... 35 | 'PrecSetupFn','kindiag_pset',... 36 | 'PrecSolveFn','kindiag_psol'); 37 | data.P = []; 38 | 39 | KINMalloc('kindiag_sys', neq, options, data); 40 | 41 | y0 = 2.0*[1:neq]'; 42 | scale = ones(neq,1); 43 | 44 | [status, y] = KINSol(y0, strategy, scale, scale); 45 | 46 | if status < 0 47 | fprintf('KINSOL failed. status = %d\n',status); 48 | else 49 | for i = 1:4:neq 50 | fprintf('%4d | %6.2f %6.2f %6.2f %6.2f\n',... 51 | i, y(i), y(i+1), y(i+2), y(i+3)); 52 | end 53 | end 54 | 55 | s = KINGetStats 56 | 57 | 58 | KINFree; 59 | 60 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/examples_ser/kindiag_pset.m: -------------------------------------------------------------------------------- 1 | function [flag, new_data] = kindiag_pset(y,yscale,fy,fscale,data) 2 | %KINDIAG_PSET - Preconditioner setup function for the KINDIAG example problem. 3 | % 4 | % See also: kindiag, KINPrecSetupFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/03/15 19:31:30 $ 9 | 10 | 11 | neq = length(y); 12 | 13 | for i = 1:neq 14 | P(i) = 0.5 / (y(i)+5.0); 15 | end 16 | 17 | new_data.P = P; % updated P in data structure 18 | 19 | flag = 0; % success -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/examples_ser/kindiag_psol.m: -------------------------------------------------------------------------------- 1 | function [x, flag, new_data] = kindiag_psol(y,yscale,fy,fscale,v,data) 2 | %KINDIAG_PSOL - Preconditioner solve function for the KINDIAG example problem. 3 | % 4 | % See also: kindiag, KINPrecSolveFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/03/15 19:31:30 $ 9 | 10 | 11 | P = data.P; 12 | 13 | neq = length(y); 14 | 15 | for i=1:neq 16 | x(i) = v(i) * P(i); 17 | end 18 | 19 | flag = 0; % success 20 | new_data = []; % data was not modified -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/examples_ser/kindiag_sys.m: -------------------------------------------------------------------------------- 1 | function [fy, flag, new_data] = kindiag_sys(y, data) 2 | %KINDIAG_SYS - System function for the KINDIAG example problem. 3 | % 4 | % See also: kindiag, KINsysFn 5 | 6 | % Radu Serban 7 | % Copyright (c) 2005, The Regents of the University of California. 8 | % $Revision: 1.2 $Date: 2006/03/15 19:31:30 $ 9 | 10 | neq = length(y); 11 | for i = 1:neq 12 | fy(i) = y(i)^2 - i^2; 13 | end 14 | flag = 0; % success 15 | new_data = []; % data was not modified -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/examples_ser/kindx.m: -------------------------------------------------------------------------------- 1 | %KINDX - KINSOL example problem (serial, dense) 2 | % Simple test problem for the Dense linear solver in KINSOL 3 | % This example solves the system 4 | % y(1)^2 + y(2)^2 = 1 5 | % y(2) = y(1)^2 6 | % 7 | % See also: kindx_sys 8 | 9 | % Radu Serban 10 | % Copyright (c) 2005, The Regents of the University of California. 11 | % $Revision: 1.1 $Date: 2006/01/06 19:00:06 $ 12 | 13 | neq = 2; 14 | 15 | strategy = 'LineSearch'; 16 | 17 | fnormtol = 1.0e-5; 18 | scsteptol = 1.0e-4; 19 | msbset = 1; % force exact Newton 20 | 21 | options = KINSetOptions('FuncNormTol', fnormtol,... 22 | 'ScaledStepTol',scsteptol,... 23 | 'LinearSolver','Dense',.... 24 | 'MaxNumSetups', msbset); 25 | 26 | KINMalloc('kindx_sys', neq, options); 27 | 28 | y0 = ones(neq,1); 29 | scale = ones(neq,1); 30 | 31 | [status, y] = KINSol(y0, strategy, scale, scale) 32 | 33 | KINFree; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/examples_ser/kindx_sys.m: -------------------------------------------------------------------------------- 1 | function [fy, flag] = kindx_sys(y) 2 | %KINDX_SYS - system function for the KINDX example problem. 3 | % 4 | % See also: kindx, KINsysFn 5 | 6 | 7 | fy(1) = y(1)^2 + y(2)^2 - 1.0; 8 | fy(2) = y(2) - y(1)^2; 9 | 10 | flag = 0; % success 11 | 12 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/kim/Contents.m: -------------------------------------------------------------------------------- 1 | % MEX binding of KINSOL functions 2 | % 3 | %-- Radu Serban @ LLNL -- April 2005 4 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/kim/kim_bjac.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = kim_bjac(y, fy, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | if isempty(data) 8 | [ret, flag] = feval(fct,y,fy); 9 | new_data = []; 10 | else 11 | [ret, flag, new_data] = feval(fct,y,fy,data); 12 | end 13 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/kim/kim_djac.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = kim_djac(y, fy, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | if isempty(data) 8 | [ret, flag] = feval(fct,y,fy); 9 | new_data = []; 10 | else 11 | [ret, flag, new_data] = feval(fct,y,fy,data); 12 | end 13 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/kim/kim_gcom.m: -------------------------------------------------------------------------------- 1 | function [flag, new_data] = kim_gcom(y, f, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | if isempty(data) 8 | flag = feval(fct,y); 9 | new_data = []; 10 | else 11 | [flag, new_data] = feval(fct,y,data); 12 | end 13 | 14 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/kim/kim_gloc.m: -------------------------------------------------------------------------------- 1 | function [gval, flag, new_data] = kim_gloc(y, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | if isempty(data) 8 | [gval, flag] = feval(fct,y); 9 | new_data = []; 10 | else 11 | [gval, flag, new_data] = feval(fct,y,data); 12 | end 13 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/kim/kim_jtv.m: -------------------------------------------------------------------------------- 1 | function [ret, new_y, flag, new_data] = kim_jtv(y, v, new_y, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | if isempty(data) 8 | [ret, new_y, flag] = feval(fct,y,v,new_y); 9 | new_data = []; 10 | else 11 | [ret, new_y, flag, new_data] = feval(fct,y,v,new_y,data); 12 | end 13 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/kim/kim_pset.m: -------------------------------------------------------------------------------- 1 | function [flag, new_data] = kim_pset(y, yscale, fy, fscale, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | if isempty(data) 8 | flag = feval(fct,y,yscale,fy,fscale); 9 | new_data =[]; 10 | else 11 | [flag, new_data] = feval(fct,y,yscale,fy,fscale,data); 12 | end 13 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/kim/kim_psol.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = kim_psol(y, yscale, fy, fscale, v, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | if isempty(data) 7 | [ret, flag] = feval(fct,y,yscale,fy,fscale,v); 8 | new_data = []; 9 | else 10 | [ret, flag, new_data] = feval(fct,y,yscale,fy,fscale,v,data); 11 | end 12 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/kinsol/kim/kim_sys.m: -------------------------------------------------------------------------------- 1 | function [ret, flag, new_data] = kim_sys(y, fct, data) 2 | 3 | % 4 | % Wrapper around the actual user-provided Matlab function 5 | % 6 | 7 | if isempty(data) 8 | [ret, flag] = feval(fct,y); 9 | new_data = []; 10 | else 11 | [ret, flag, new_data] = feval(fct,y,data); 12 | end 13 | 14 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/Contents.m: -------------------------------------------------------------------------------- 1 | % SUNDIALS NVECTOR operations 2 | % 3 | % Functions: 4 | % 5 | % N_VMax - returns the largest element of x 6 | % N_VMaxNorm - returns the maximum norm of x 7 | % N_VMin - returns the smallest element of x 8 | % N_VDotProd - returns the dot product of two vectors 9 | % N_VWrmsNorm - returns the weighted root mean square norm of x 10 | % N_VWL2Norm - returns the weighted Euclidean L2 norm of x 11 | % N_VL1Norm - returns the L1 norm of x 12 | % 13 | % NOTE For serial vectors, all of the above operations default to 14 | % the corresponding MATLAB functions. For parallel vectors, they 15 | % can be used either on the local portion of the distributed vector 16 | % or on the global vector (in which case they will trigger an MPI 17 | % allreduce operation). 18 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/N_VDotProd.m: -------------------------------------------------------------------------------- 1 | function ret = N_VDotProd(x,y,comm) 2 | %N_VDotProd returns the dot product of two vectors 3 | % 4 | % Usage: RET = N_VDotProd ( X, Y [, COMM] ) 5 | % 6 | %If COMM is not present, N_VDotProd returns the dot product of the 7 | %local portions of X and Y. Otherwise, it returns the global dot 8 | %product. 9 | 10 | % Radu Serban 11 | % Copyright (c) 2005, The Regents of the University of California. 12 | % $Revision: 1.1 $Date: 2006/01/06 19:00:10 $ 13 | 14 | 15 | if nargin == 2 16 | 17 | ret = dot(x,y); 18 | 19 | else 20 | 21 | ldot = dot(x,y); 22 | gdot = 0.0; 23 | MPI_Allreduce(ldot,gdot,'SUM',comm); 24 | ret = gdot; 25 | 26 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/N_VL1Norm.m: -------------------------------------------------------------------------------- 1 | function ret = N_VL1Norm(x,comm) 2 | %N_VL1Norm returns the L1 norm of x 3 | % 4 | % Usage: RET = N_VL1Norm ( X [, COMM] ) 5 | % 6 | %If COMM is not present, N_VL1Norm returns the L1 norm of 7 | %the local portion of X. Otherwise, it returns the global 8 | %L1 norm.. 9 | 10 | % Radu Serban 11 | % Copyright (c) 2005, The Regents of the University of California. 12 | % $Revision: 1.1 $Date: 2006/01/06 19:00:10 $ 13 | 14 | if nargin == 1 15 | 16 | ret = norm(x,1); 17 | 18 | else 19 | 20 | lnrm = norm(x,1); 21 | gnrm = 0.0; 22 | MPI_Allreduce(lnrm,gnrm,'MAX',comm); 23 | ret = gnrm; 24 | 25 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/N_VMax.m: -------------------------------------------------------------------------------- 1 | function ret = N_VMax(x,comm) 2 | %N_VMax returns the largest element of x 3 | % 4 | % Usage: RET = N_VMax ( X [, COMM] ) 5 | % 6 | %If COMM is not present, N_VMax returns the maximum value of 7 | %the local portion of X. Otherwise, it returns the global 8 | %maximum value. 9 | 10 | % Radu Serban 11 | % Copyright (c) 2005, The Regents of the University of California. 12 | % $Revision: 1.1 $Date: 2006/01/06 19:00:10 $ 13 | 14 | if nargin == 1 15 | 16 | ret = max(x); 17 | 18 | else 19 | 20 | lmax = max(x); 21 | gmax = 0.0; 22 | MPI_Allreduce(lmax,gmax,'MAX',comm); 23 | ret = gmax; 24 | 25 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/N_VMaxNorm.m: -------------------------------------------------------------------------------- 1 | function ret = N_VMaxNorm(x, comm) 2 | %N_VMaxNorm returns the L-infinity norm of x 3 | % 4 | % Usage: RET = N_VMaxNorm ( X [, COMM] ) 5 | % 6 | %If COMM is not present, N_VMaxNorm returns the L-infinity norm 7 | %of the local portion of X. Otherwise, it returns the global 8 | %L-infinity norm.. 9 | 10 | % Radu Serban 11 | % Copyright (c) 2005, The Regents of the University of California. 12 | % $Revision: 1.1 $Date: 2006/01/06 19:00:10 $ 13 | 14 | if nargin == 1 15 | 16 | ret = norm(x,'inf'); 17 | 18 | else 19 | 20 | lnrm = norm(x,'inf'); 21 | gnrm = 0.0; 22 | MPI_Allreduce(lnrm,gnrm,'MAX',comm); 23 | ret = gnrm; 24 | 25 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/N_VMin.m: -------------------------------------------------------------------------------- 1 | function ret = N_VMin(x,comm) 2 | %N_VMin returns the smallest element of x 3 | % Usage: RET = N_VMin ( X [, COMM] ) 4 | % 5 | %If COMM is not present, N_VMin returns the minimum value of 6 | %the local portion of X. Otherwise, it returns the global 7 | %minimum value. 8 | 9 | % Radu Serban 10 | % Copyright (c) 2005, The Regents of the University of California. 11 | % $Revision: 1.1 $Date: 2006/01/06 19:00:10 $ 12 | 13 | if nargin == 1 14 | 15 | ret = min(x); 16 | 17 | else 18 | 19 | lmin = min(x); 20 | gmin = 0.0; 21 | MPI_Allreduce(lmin,gmin,'MIN',comm); 22 | ret = gmin; 23 | 24 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/N_VWL2Norm.m: -------------------------------------------------------------------------------- 1 | function ret = N_VWL2Norm(x,w,comm) 2 | %N_VWL2Norm returns the weighted Euclidean L2 norm of x 3 | % with weight vector w: 4 | % sqrt [(sum (i = 0 to N-1) {(x[i]*w[i])^2})] 5 | % 6 | % Usage: RET = N_VWL2Norm ( X, W [, COMM] ) 7 | % 8 | %If COMM is not present, N_VWL2Norm returns the weighted L2 9 | %norm of the local portion of X. Otherwise, it returns the 10 | %global weighted L2 norm.. 11 | 12 | % Radu Serban 13 | % Copyright (c) 2005, The Regents of the University of California. 14 | % $Revision: 1.1 $Date: 2006/01/06 19:00:10 $ 15 | 16 | if nargin == 2 17 | 18 | ret = dot(x.^2,w.^2); 19 | ret = sqrt(ret); 20 | 21 | else 22 | 23 | lnrm = dot(x.^2,w.^2); 24 | gnrm = 0.0; 25 | MPI_Allreduce(lnrm,gnrm,'SUM',comm); 26 | 27 | ret = sqrt(gnrm); 28 | 29 | end -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/N_VWrmsNorm.m: -------------------------------------------------------------------------------- 1 | function ret = N_VWrmsNorm(x,w,comm) 2 | %N_VWrmsNorm returns the weighted root mean square norm of x 3 | %with weight vector w: 4 | % sqrt [(sum (i = 0 to N-1) {(x[i]*w[i])^2})/N] 5 | % 6 | % Usage: RET = N_VWrmsNorm ( X, W [, COMM] ) 7 | % 8 | %If COMM is not present, N_VWrmsNorm returns the WRMS norm 9 | %of the local portion of X. Otherwise, it returns the global 10 | %WRMS norm.. 11 | 12 | % Radu Serban 13 | % Copyright (c) 2005, The Regents of the University of California. 14 | % $Revision: 1.1 $Date: 2006/01/06 19:00:11 $ 15 | 16 | if nargin == 2 17 | 18 | ret = dot(x.^2,w.^2); 19 | ret = sqrt(ret/length(x)); 20 | 21 | else 22 | 23 | lnrm = dot(x.^2,w.^2); 24 | gnrm = 0.0; 25 | MPI_Allreduce(lnrm,gnrm,'SUM',comm); 26 | 27 | ln = length(x); 28 | gn = 0; 29 | MPI_Allreduce(ln,gn,'SUM',comm); 30 | 31 | ret = sqrt(gnrm/gn); 32 | 33 | end 34 | 35 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/src/nvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ----------------------------------------------------------------- 3 | * $Revision: 1.2 $ 4 | * $Date: 2006/10/09 23:56:25 $ 5 | * ----------------------------------------------------------------- 6 | * Programmer: Radu Serban @ LLNL 7 | * ----------------------------------------------------------------- 8 | * Copyright (c) 2005, The Regents of the University of California. 9 | * Produced at the Lawrence Livermore National Laboratory. 10 | * All rights reserved. 11 | * For details, see the LICENSE file. 12 | * ----------------------------------------------------------------- 13 | * Header file for the MNVECTOR Matlab interface. 14 | * ----------------------------------------------------------------- 15 | */ 16 | 17 | #ifndef _NVM_H 18 | #define _NVM_H 19 | 20 | #ifdef __cplusplus /* wrapper to enable C++ usage */ 21 | extern "C" { 22 | #endif 23 | 24 | #include 25 | #include "mex.h" 26 | 27 | /* 28 | * ------------------ 29 | * Vector functions 30 | * ------------------ 31 | */ 32 | 33 | void InitVectors(); 34 | N_Vector NewVector(int n); 35 | 36 | void PutData(N_Vector v, double *data, int n); 37 | void GetData(N_Vector v, double *data, int n); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/nvector/src/nvm_ops.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ----------------------------------------------------------------- 3 | * $Revision: 1.2 $ 4 | * $Date: 2006/10/09 23:56:25 $ 5 | * ----------------------------------------------------------------- 6 | * Programmer: Radu Serban @ LLNL 7 | * ----------------------------------------------------------------- 8 | * Copyright (c) 2005, The Regents of the University of California. 9 | * Produced at the Lawrence Livermore National Laboratory. 10 | * All rights reserved. 11 | * For details, see the LICENSE file. 12 | * ----------------------------------------------------------------- 13 | * Vector constructors for the SUNDIALS Matlab interfaces. 14 | * ----------------------------------------------------------------- 15 | */ 16 | 17 | #include 18 | #include "nvm.h" 19 | 20 | void PutData(N_Vector v, double *data, int n) 21 | { 22 | double *vdata; 23 | int i; 24 | 25 | vdata = N_VGetArrayPointer(v); 26 | 27 | for(i=0;i 18 | #include "nvm.h" 19 | #include 20 | 21 | void InitVectors() 22 | {} 23 | 24 | N_Vector NewVector(int n) 25 | { 26 | N_Vector v; 27 | v = N_VNew_Serial((long int)n); 28 | return(v); 29 | } 30 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/putils/Contents.m: -------------------------------------------------------------------------------- 1 | % Parallel utilities for the Matlab SUNDIALS interfaces 2 | % 3 | % Functions: 4 | % 5 | % mpirun - runs parallel examples 6 | % mpiruns - runs the parallel example on a child MATLAB process 7 | % mpistart - lamboot and MPI_Init master (if required) 8 | 9 | 10 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/putils/mpirun.m: -------------------------------------------------------------------------------- 1 | function [] = mpirun(fct,npe,dbg) 2 | %MPIRUN runs parallel examples. 3 | % 4 | % Usage: MPIRUN ( FCT , NPE [, DBG] ) 5 | % 6 | % FCT - function to be executed on all MATLAB processes. 7 | % NPE - number of processes to be used (including the master). 8 | % DBG - flag for debugging [ true | {false} ] 9 | % If true, spawn MATLAB child processes with a visible xterm. 10 | 11 | % Radu Serban 12 | % Copyright (c) 2005, The Regents of the University of California. 13 | % $Revision: 1.2 $Date: 2006/03/07 01:20:01 $ 14 | 15 | ih = isa(fct,'function_handle'); 16 | is = isa(fct,'char'); 17 | if ih 18 | sh = functions(fct); 19 | fct_str = sh.function; 20 | elseif is 21 | fct_str = fct; 22 | else 23 | error('mpirun:: Unrecognized function'); 24 | end 25 | 26 | if exist(fct_str) ~= 2 27 | err_msg = sprintf('mpirun:: Function %s not in search path.',fct_str); 28 | error(err_msg); 29 | end 30 | 31 | nslaves = npe-1; 32 | mpistart(nslaves); 33 | 34 | debug = false; 35 | if (nargin > 2) & dbg 36 | debug = true; 37 | end 38 | 39 | cmd_slaves = sprintf('mpiruns(''%s'')',fct_str); 40 | 41 | if debug 42 | cmd = 'xterm'; 43 | args = {'-sb','-sl','5000','-e','matlab','-nosplash','-nojvm','-r',cmd_slaves}; 44 | else 45 | cmd = 'matlab'; 46 | args = {'-nosplash','-nojvm','-r',cmd_slaves}; 47 | end 48 | 49 | [info children errs] = MPI_Comm_spawn(cmd,args,nslaves,'NULL',0,'SELF'); 50 | 51 | [info NEWORLD] = MPI_Intercomm_merge(children,0); 52 | 53 | % Put the MPI communicator in the global workspace 54 | global sundials_MPI_comm; 55 | sundials_MPI_comm = NEWORLD; 56 | 57 | % Get rank of current process and put it in the global workspace 58 | [status mype] = MPI_Comm_rank(NEWORLD); 59 | global sundials_MPI_rank; 60 | sundials_MPI_rank = mype; 61 | 62 | % Call the user main program 63 | feval(fct,NEWORLD); 64 | 65 | % Clear the global MPI communicator variable 66 | clear sundials_MPI_comm 67 | 68 | -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/putils/mpiruns.m: -------------------------------------------------------------------------------- 1 | function [] = mpiruns(fct) 2 | %MPIRUNS runs the parallel example on a child MATLAB process. 3 | % 4 | % Usage: MPIRUNS ( FCT ) 5 | % 6 | % This function should not be called directly. It is called 7 | % by mpirun on the spawned child processes. 8 | 9 | % Radu Serban 10 | % Copyright (c) 2005, The Regents of the University of California. 11 | % $Revision: 1.2 $Date: 2006/03/07 01:20:01 $ 12 | 13 | clc; 14 | 15 | [dummy hostname]=system('hostname'); 16 | fprintf('mpiruns :: child MATLAB process on %s\n',hostname); 17 | 18 | MPI_Init; 19 | 20 | MPI_Errhandler_set('WORLD','RETURN'); 21 | 22 | [info parent] = MPI_Comm_get_parent; 23 | 24 | fprintf('mpiruns :: waiting to merge MPI intercommunicators ... '); 25 | [info NEWORLD] = MPI_Intercomm_merge(parent,1); 26 | fprintf('OK!\n\n'); 27 | 28 | MPI_Errhandler_set(NEWORLD,'RETURN'); 29 | 30 | % Put the MPI communicator in the global workspace 31 | global sundials_MPI_comm; 32 | sundials_MPI_comm = NEWORLD; 33 | 34 | % Get rank of current process and put it in the global workspace 35 | [status mype] = MPI_Comm_rank(NEWORLD); 36 | global sundials_MPI_rank; 37 | sundials_MPI_rank = mype; 38 | 39 | fprintf('mpiruns :: MPI rank: %d\n\n',mype); 40 | 41 | fprintf('----------------------------------------------------------------\n\n'); 42 | 43 | % Call the user main program 44 | feval(fct,NEWORLD); 45 | 46 | % Clear the global MPI communicator variable 47 | clear sundials_MPI_comm 48 | 49 | % Finalize MPI on this slave 50 | MPI_Finalize; -------------------------------------------------------------------------------- /WormSim/sundials-2.3.0/sundialsTB/startup_STB.in: -------------------------------------------------------------------------------- 1 | % STARTUP_STB path/environment setup script for sundialsTB 2 | % Add to or call from Matlab's startup.m 3 | 4 | % Radu Serban 5 | % Copyright (c) 2005, The Regents of the University of California. 6 | % $Revision: 1.3 $Date: 2006/07/27 21:27:13 $ 7 | 8 | stb_path = '@STB_PATH@'; 9 | 10 | stb = fullfile(stb_path,'sundialsTB'); 11 | 12 | if ~exist(stb, 'dir') 13 | clear stb 14 | warning('SUNDIALS Toolbox not found'); 15 | return 16 | end 17 | 18 | % Add top-level directory to path 19 | 20 | addpath(stb); 21 | 22 | % Add sundialsTB components to path 23 | 24 | q = fullfile(stb,'cvodes'); 25 | if exist(q, 'dir') 26 | addpath(q); 27 | q = fullfile(stb,'cvodes','cvm'); 28 | addpath(q); 29 | end 30 | 31 | q = fullfile(stb,'idas'); 32 | if exist(q, 'dir') 33 | addpath(q); 34 | q = fullfile(stb,'idas','idm'); 35 | addpath(q); 36 | end 37 | 38 | q = fullfile(stb,'kinsol'); 39 | if exist(q, 'dir') 40 | addpath(q); 41 | q = fullfile(stb,'kinsol','kim'); 42 | addpath(q); 43 | end 44 | 45 | q = fullfile(stb,'nvector'); 46 | if exist(q, 'dir') 47 | addpath(q); 48 | end 49 | 50 | q = fullfile(stb,'putils'); 51 | if exist(q, 'dir') 52 | addpath(q); 53 | end 54 | 55 | clear stb q 56 | 57 | -------------------------------------------------------------------------------- /assembly/Robot_Worm_ESP32_assembly.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/assembly/Robot_Worm_ESP32_assembly.docx -------------------------------------------------------------------------------- /assembly/Robot_Worm_RaspberryPi_assembly.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/assembly/Robot_Worm_RaspberryPi_assembly.docx -------------------------------------------------------------------------------- /assembly/Worm_Body.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/assembly/Worm_Body.stl -------------------------------------------------------------------------------- /assembly/Worm_Head.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/assembly/Worm_Head.stl -------------------------------------------------------------------------------- /assembly/Worm_RPi_PWM_Stand.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/assembly/Worm_RPi_PWM_Stand.stl -------------------------------------------------------------------------------- /assembly/Worm_Stand.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/assembly/Worm_Stand.stl -------------------------------------------------------------------------------- /assembly/Worm_battery_stand.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/assembly/Worm_battery_stand.stl -------------------------------------------------------------------------------- /docs/C_elegans_robot.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openworm/robots/1d66c4f9925ceaaa3cab0042f7544eec1371d460/docs/C_elegans_robot.docx -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight --------------------------------------------------------------------------------