{"id":23,"date":"2025-02-23T21:54:52","date_gmt":"2025-02-23T21:54:52","guid":{"rendered":"https:\/\/proteus-analytics.com\/?p=23"},"modified":"2025-08-26T07:28:37","modified_gmt":"2025-08-26T07:28:37","slug":"leveraging-cvode-with-the-robertson-problem","status":"publish","type":"post","link":"https:\/\/proteus-analytics.com\/index.php\/2025\/02\/23\/leveraging-cvode-with-the-robertson-problem\/","title":{"rendered":"Leveraging CVODE With the Robertson Problem"},"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\">Leveraging CVODE With the Robertson Problem<\/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: CVODE, stiffness, chemical kinetics<\/span><\/div><\/div>\n  \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>TL;DR.<\/strong> The three\u2011species Robertson kinetics form a classic stiff ODE system\u2014perfect to demonstrate CVODE\u2019s BDF\/Newton toolbox and tolerance strategy.<\/div><\/div>\n  \n\n  <h2 class=\"wp-block-heading\">The model<\/h2>\n  \n  \\[\\begin{aligned}\n  y_1&#8242; &#038; = -k_1 y_1 + k_3 y_2 y_3,\\\\\n  y_2&#8242; &#038; = k_1 y_1 &#8211; k_2 y_2^2 &#8211; k_3 y_2 y_3,\\\\\n  y_3&#8242; &#038; = k_2 y_2^2\\,,\\quad (k_1{=}0.04,\\ k_2{=}10^4,\\ k_3{=}3\\cdot10^7)\n  \\end{aligned}\\]\n  \n\n  <h2 class=\"wp-block-heading\">Why stiffness matters<\/h2>\n  <ul class=\"wp-block-list\">\n    <li>Explicit methods choke on fast transients \u2192 tiny steps.<\/li>\n    <li>Implicit BDF tracks slow manifolds efficiently.<\/li>\n  <\/ul>\n\n  <h2 class=\"wp-block-heading\">CVODE setup (dense)<\/h2>\n  \n  <pre class=\"wp-block-code\"><code class=\"language-c\">\/\/ Outline: init, tolerances, linear solver, integrate\nSUNContext ctx; SUNContext_Create(0, &ctx);\nN_Vector y = N_VNew_Serial(3, ctx);\nNV_Ith_S(y,0)=1.0; NV_Ith_S(y,1)=0.0; NV_Ith_S(y,2)=0.0;\nvoid *cvode = CVodeCreate(CV_BDF, ctx);\nCVodeInit(cvode, f, 0.0, y);\nCVodeSStolerances(cvode, 1e-6, 1e-10);\nSUNMatrix A = SUNDenseMatrix(3,3,ctx);\nSUNLinearSolver LS = SUNLinSol_Dense(y, A, ctx);\nCVodeSetLinearSolver(cvode, LS, A);\n\/\/ ... integrate, query stats ...<\/code><\/pre>\n  \n\n  \n  <details class=\"is-layout-flow wp-block-details-is-layout-flow\"><summary><strong>Common pitfalls<\/strong><\/summary><p>Missing rpath \u2192 add <code>-Wl,-rpath,$HOME\/sundials-install\/lib<\/code>. Context required (v6+) \u2192 use <code>SUNContext_Create<\/code> and pass to vectors\/solvers.<\/p><\/details>\n  \n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Leveraging CVODE With the Robertson Problem By Ree\u2022[DATE]\u2022~[READING TIME] min\u2022Tags: CVODE, stiffness, chemical kinetics TL;DR. The three\u2011species Robertson kinetics form a classic<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/proteus-analytics.com\/index.php\/2025\/02\/23\/leveraging-cvode-with-the-robertson-problem\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":612,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-23","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\/23","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=23"}],"version-history":[{"count":42,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":1037,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/posts\/23\/revisions\/1037"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/media\/612"}],"wp:attachment":[{"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/proteus-analytics.com\/index.php\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}