{"id":7,"date":"2025-02-21T18:37:41","date_gmt":"2025-02-21T18:37:41","guid":{"rendered":"https:\/\/proteus-analytics.com\/?p=7"},"modified":"2026-01-19T20:57:12","modified_gmt":"2026-01-19T20:57:12","slug":"implementing-the-sundials-suite-for-solving-differential-equations","status":"publish","type":"post","link":"https:\/\/proteus-analytics.com\/index.php\/2025\/02\/21\/implementing-the-sundials-suite-for-solving-differential-equations\/","title":{"rendered":"Implementing the SUNDIALS Suite for Solving Differential Equations"},"content":{"rendered":"\n<div class=\"wp-block-group pa-post\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n  <h1 class=\"wp-block-heading\">Implementing the SUNDIALS Suite for Solving Differential Equations<\/h1>\n  \n  <div class=\"wp-block-group pa-meta\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\"><span>By <strong>Ree<\/strong><\/span><span class=\"sep\">\u2022<\/span><span>[DATE]<\/span><span class=\"sep\">\u2022<\/span><span>~[READING TIME] min<\/span><span class=\"sep\">\u2022<\/span><span>Tags: SUNDIALS, CVODE, build<\/span><\/div><\/div>\n  \n<p>[latexpage] The <a href=\"https:\/\/computing.llnl.gov\/projects\/sundials\">SUNDIALS <\/a>(SUite of Nonlinear and DIfferential\/ALgebraic equation Solvers) suite, with its component CVODE, is an <a href=\"https:\/\/www.llnl.gov\/article\/49201\/llnls-sundials-team-wins-prestigious-siamacm-prize\">award-winning<\/a> set of open source ODE solvers from <a href=\"https:\/\/www.llnl.gov\/\">Lawrence Livermore National Labs<\/a>. It is highly regarded in the scientific computing community for solving ordinary differential equations (ODEs). CVODE, specifically, is designed to handle both stiff and non-stiff systems efficiently through variable step size and order methods, using Backward Differentiation Formulas (BDF) for stiff problems and Adams-Moulton formulas for non-stiff problems. This adaptability makes CVODE extremely valuable for a wide range of applications in chemical kinetics, biological systems, and engineering dynamics where the characteristics of the system can change dramatically over the simulation period. CVODE&#8217;s ability to integrate with various linear solver libraries and its support for root finding makes it an all-encompassing tool for researchers and engineers needing robust, flexible solutions to complex ODEs in their models. Its extensive features and reliable performance underpin its cherished status in solving differential equations efficiently and accurately. It is therefore important to leverage this highly optimized component, through use of examples, in both MATLAB and our own set of differential equations.<\/p>\n\n<h2 class=\"wp-block-heading\">Installing and Configuring on WSL Ubuntu<\/h2>\n\n<p>Follow the procedure below to install SUNDIALS (and hence CVODE) as documented in this informative <a href=\"https:\/\/medium.com\/theta-hat\/installing-sundials-equation-solvers-on-ubuntu-4178da3258f4\">Medium article<\/a>. In fact, if you hate all those garbage paywalls forcing you to pay the \\$5 monthly subscription, just copy(paste) the Medium link into <a href=\"https:\/\/archive.is\/\">archive.is<\/a> to retrieve the archived website, circumventing the need for extensions or fancy scripting. In your WSL Ubuntu terminal type:<\/p>\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-b937140e77826d923377d250dfb6e876\"><code>cd ~\nwget https:\/\/github.com\/LLNL\/sundials\/releases\/download\/v7.2.1\/sundials-7.2.1.tar.gz\nmkdir sundials\ntar -xzvf sundials-7.2.1.tar.gz -C sundials\/<\/code><\/pre>\n\n<p>The above commands download and extract the sundials files to the <code>\/sundials<\/code> directory. Now make use of <code>cmake<\/code> (which you should have installed by now) by typing the following commands:<\/p>\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-87645ab883a75a0edc033e7d06857215\"><code>cd sundials\nmkdir build-sundials-7.2.1\nsudo mkdir \/opt\/sundials\nsudo mkdir \/opt\/sundials\/examples\nsudo chown $USER -R \/opt\/sundials\/\nINSTDIR=\/opt\/sundials\nsudo apt-get install -y libopenblas-dev\ncd build-sundials-7.2.1\ncmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_SIZE=64 -DCMAKE_INSTALL_PREFIX=\\$INSTDIR -DEXAMPLES_INSTALL_PATH=\\$INSTDIR\/examples ..\/sundials-7.2.1<\/code><\/pre>\n\n<p>Finally <code>make<\/code> and <code>install<\/code> and you have a fresh new SUNDIALS to play with! All code and examples are located in your <code>\/opt\/sundials\/examples\/<\/code> folder for modification. You will need to navigate to the appropriate example and modify the c code, then run <code>make<\/code> and finally <code>make install<\/code> to compile and link the prebuilt executables (<code>&lt;executable example&gt;<\/code>). See the next walkthrough for details on how to solve ordinary differential equations.<\/p>\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-e75e1b0cf1f760e7b311620834be0ca8\"><code>make\nmake install\n.\/&lt;example binary&gt;<\/code><\/pre>\n\n<br>\n\n  \n  <div class=\"wp-block-group pa-callout\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\"><strong>Goal.<\/strong> Install SUNDIALS with LAPACK\/BLAS, place examples under a clean prefix, and verify a CVODE build on WSL Ubuntu.<\/div><\/div>\n  \n\n  <h2 class=\"wp-block-heading\">Install (WSL Ubuntu)<\/h2>\n  \n  <pre class=\"wp-block-code\"><code class=\"language-bash\">cd ~\nwget https:\/\/github.com\/LLNL\/sundials\/releases\/download\/v7.2.1\/sundials-7.2.1.tar.gz\nmkdir -p sundials && tar -xzvf sundials-7.2.1.tar.gz -C sundials\/\ncd sundials && mkdir build-sundials-7.2.1\nsudo mkdir -p \/opt\/sundials \/opt\/sundials\/examples && sudo chown $USER -R \/opt\/sundials\nINSTDIR=\/opt\/sundials\nsudo apt-get install -y libopenblas-dev\ncd build-sundials-7.2.1\ncmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_SIZE=64 -DCMAKE_INSTALL_PREFIX=$INSTDIR -DEXAMPLES_INSTALL_PATH=$INSTDIR\/examples ..\/sundials-7.2.1\nmake -j && make install<\/code><\/pre>\n  \n\n  <h2 class=\"wp-block-heading\">Run an example<\/h2>\n  \n  <pre class=\"wp-block-code\"><code class=\"language-bash\">export LD_LIBRARY_PATH=$INSTDIR\/lib:$LD_LIBRARY_PATH\n$INSTDIR\/examples\/cvode\/serial\/cvRoberts_dns<\/code><\/pre>\n  \n\n  \n  <details class=\"is-layout-flow wp-block-details-is-layout-flow\"><summary>Linking tips<\/summary><p>Prefer a permanent rpath in your Makefile: <code>-Wl,-rpath,$INSTDIR\/lib<\/code> to avoid setting <code>LD_LIBRARY_PATH<\/code>.<\/p><\/details>\n  \n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Implementing the SUNDIALS Suite for Solving Differential Equations By Ree\u2022[DATE]\u2022~[READING TIME] min\u2022Tags: SUNDIALS, CVODE, build Goal. Install SUNDIALS with LAPACK\/BLAS, place examples<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/proteus-analytics.com\/index.php\/2025\/02\/21\/implementing-the-sundials-suite-for-solving-differential-equations\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":384,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-7","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":7,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":1167,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/posts\/7\/revisions\/1167"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/media\/384"}],"wp:attachment":[{"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}