<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi David,<br>
    </p>
    <div class="moz-cite-prefix">Le 27/10/2021 à 16:18, CHEZE David
      227480 a écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:cd8a0918be174ee6a1c15f2277181b03@cea.fr">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}h2
        {mso-style-priority:9;
        mso-style-link:"Titre 2 Car";
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:18.0pt;
        font-family:"Times New Roman",serif;
        font-weight:bold;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}code
        {mso-style-priority:99;
        font-family:"Courier New";}pre
        {mso-style-priority:99;
        mso-style-link:"Préformaté HTML Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}span.Titre2Car
        {mso-style-name:"Titre 2 Car";
        mso-style-priority:9;
        mso-style-link:"Titre 2";
        font-family:"Calibri Light",sans-serif;
        color:#2E74B5;}span.PrformatHTMLCar
        {mso-style-name:"Préformaté HTML Car";
        mso-style-priority:99;
        mso-style-link:"Préformaté HTML";
        font-family:Consolas;}span.line
        {mso-style-name:line;}span.EmailStyle24
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}span.EmailStyle25
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}div.WordSection1
        {page:WordSection1;}ol
        {margin-bottom:0cm;}ul
        {margin-bottom:0cm;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB">Hi Stéphane,<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB">I tested the cvode_solve() function in my case
            study cited below and it actually ran 40% faster than the
            previous ode(‘stiff’,…), with easy one-to-one function’s
            parameters replacement (in my case including the list
            syntax, with function’s multiple parameters, gradient
            function, simple tolerance specifications).<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB">As you advised, I need to investigate moving
            the differential equation code from Scilab to fortran
            external function to reduce further the simulation time. </span></p>
      </div>
    </blockquote>
    <p>As I already said, only the right hand side would need to be
      translated.</p>
    <p>S.<br>
    </p>
    <blockquote type="cite"
      cite="mid:cd8a0918be174ee6a1c15f2277181b03@cea.fr">
      <div class="WordSection1">
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB"><o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB">Thank you for this new module, staying updated
            with Sundials !<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB">Best,<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D"
            lang="EN-GB">David Chèze             
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">tel.
            +33(0)479792130 – CEA ☼ INES – LITEN/DTS/SIRE/LELA –  Le
            Bourget du Lac (73), FRANCE – bât. HELIOS/3108
          </span><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><a
              href="Liten.cea.fr" moz-do-not-send="true"><span
                style="color:#1F497D">Liten.cea.fr</span></a><o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0cm 0cm 0cm">
            <p class="MsoNormal"><b><span
                  style="font-size:11.0pt;font-family:"Calibri",sans-serif">De :</span></b><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif">
                users <a class="moz-txt-link-rfc2396E" href="mailto:users-bounces@lists.scilab.org"><users-bounces@lists.scilab.org></a>
                <b>De la part de</b> Stéphane Mottelet<br>
                <b>Envoyé :</b> lundi 25 octobre 2021 16:35<br>
                <b>À :</b> Users mailing list for Scilab
                <a class="moz-txt-link-rfc2396E" href="mailto:users@lists.scilab.org"><users@lists.scilab.org></a><br>
                <b>Objet :</b> [Scilab-users] Sundials ode solvers<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p>Hi all,<o:p></o:p></p>
        <p>As discussed in this thread last month<o:p></o:p></p>
        <p><a
href="https://antispam.utc.fr/proxy/v3?i=WjB4M1dJWGJJMnNGTHV5MuAPDwEdQko7KGyaWIIeme0&r=Skk2OVhvdXl2cm1uOWJtRLRPDrgr4YiCABksjbHu_Gv8eNkcUiMzd6MxV8KbAPI5&f=M2FwZHlGNnU1aUlkc09ZNN6FtQAZUfRagBYPQiUfaoT45ZkXHKKVm0cOGvv2yMCS&u=https%3A//www.mail-archive.com/users%40lists.scilab.org/msg10679.html&k=CXOq"
            moz-do-not-send="true">https://www.mail-archive.com/users@lists.scilab.org/msg10679.html</a><o:p></o:p></p>
        <p>I am glad to annouce that a first version of the 
          sci-sundials toolbox (maybe part of Scilab in the future) is
          available on Atoms in the "Differential Equations" category
          (refresh the package list if you don't see it).  To have an
          idea of its features I pasted below the content of the
          README.md file on the gitlab project of sci-sundials (<a
href="https://antispam.utc.fr/proxy/v3?i=WjB4M1dJWGJJMnNGTHV5MuAPDwEdQko7KGyaWIIeme0&r=Skk2OVhvdXl2cm1uOWJtRLRPDrgr4YiCABksjbHu_Gv8eNkcUiMzd6MxV8KbAPI5&f=M2FwZHlGNnU1aUlkc09ZNN6FtQAZUfRagBYPQiUfaoT45ZkXHKKVm0cOGvv2yMCS&u=https%3A//gitlab.com/mottelet/sci-sundials/&k=CXOq"
            moz-do-not-send="true">https://gitlab.com/mottelet/sci-sundials/</a>).<o:p></o:p></p>
        <p>If you appreciate the work and want to help, doc, demos, or
          even more if you know how to code in C and C++ you are welcome
          !<o:p></o:p></p>
        <p>S.<o:p></o:p></p>
        <h2>What has been done and what is to be done<o:p></o:p></h2>
        <p>Until now only CVODE has been interfaced but many common
          features have been developped in the OdeManager class, hence
          interfacing IDA will be quite easy. ARKODE (various modern
          explicit, implicit and mixed explicit/implicit Runge-Kutta
          solvers) does not exist in the old 2.4.0 version of Sundials
          which is used in Scilab hence won't be interfaced unless an
          upgrade is done (Sundials is now at version 5.7.0). The
          support of Sparse Jacobians is also missing for the same
          reason.<o:p></o:p></p>
        <h2>Features<o:p></o:p></h2>
        <p>The CVODE gateway cvode_solve() implements the following
          features which were missing by the legacy
          LSODE/LSODA/LSODAR/... ode() gateway :<o:p></o:p></p>
        <ul type="disc">
          <li class="MsoNormal"
            style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0
            level1 lfo1">
            full a posteriori access to solver continuous extension of
            solution at arbitrary points via a MList output when only
            one lhs is given:<o:p></o:p></li>
        </ul>
        <pre><span class="line">sol = cvode_solve(f, [t0 tf], y0)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">t = linspace(t0, tf, 1000)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">plot(t, sol(t)) </span><o:p></o:p></pre>
        <p>The <code><span style="font-size:10.0pt">sol</span></code>
          MList fields gathers all information related to the obtained
          solution (time steps, solution at time steps, events, ...).
          The solver can be restarted by giving the MLlist as first
          argument to
          <code><span style="font-size:10.0pt">cvode_extend</span></code>
          :<o:p></o:p></p>
        <pre><span class="line">sol2 = cvode_extend(sol, tx, ...)</span><o:p></o:p></pre>
        <p>where <code><span style="font-size:10.0pt">tx</span></code>
          is the time point to which solution has to be extended. The
          options of the call that yielded
          <code><span style="font-size:10.0pt">sol</span></code> are
          used and can be changed as optional named parameters after
          <code><span style="font-size:10.0pt">tx</span></code>.<o:p></o:p></p>
        <ul type="disc">
          <li class="MsoNormal"
            style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l5
            level1 lfo2">
            a user-friendly access to solver options via optional named
            parameters in cvode_solve call, i.e.<o:p></o:p></li>
        </ul>
        <pre><span class="line">cvode_solve(f, tspan, y0, h0=0.01, rtol=1e-3)</span><o:p></o:p></pre>
        <ul type="disc">
          <li class="MsoNormal"
            style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l4
            level1 lfo3">
            a really simpler way to give time span of integration
            allowing to choose between error driven solver internal time
            steps and user fixed time steps, i.e.<o:p></o:p></li>
        </ul>
        <pre><span class="line">[t,y] = cvode_solve(f, [t0 tf], y0)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">[t,y] = cvode_solve(f, [t0 t1 ... tf], y0)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">[t,t] = cvode_solve(f, tspan, y0, t0=0)</span><o:p></o:p></pre>
        <p>the latter style being the closest to actual <code><span
              style="font-size:10.0pt">ode()</span></code> behavior
          where solution is by default given at user time steps and
          <code><span style="font-size:10.0pt">t0</span></code> is not
          necessarily equal to
          <code><span style="font-size:10.0pt">tspan(1)</span></code>,
          which is the default in the two former calls above.<o:p></o:p></p>
        <ul type="disc">
          <li class="MsoNormal"
            style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l3
            level1 lfo4">
            a better and user-friendly specification of events via a
            variable number of outputs event function (giving value of
            event equations, wheter to stop integration for a given
            event and event direction selection), minimal style beeing a
            single output. Information about events is also simpler to
            get:<o:p></o:p></li>
        </ul>
        <pre><span class="line">function [eq,term,dir] = evfun(t,y)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">    eq = y(1)-1.7;</span><code><o:p></o:p></code></pre>
        <pre><span class="line">    term = %f;</span><code><o:p></o:p></code></pre>
        <pre><span class="line">    dir  = 1;</span><code><o:p></o:p></code></pre>
        <pre><span class="line">end</span><code><o:p></o:p></code></pre>
        <pre><span class="line">[t,y,te,ye,ie] = cvode_solve(f, tspan, y0, events = evfun)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">sol = cvode_solve(f, tspan, y0, events = evfun)</span><o:p></o:p></pre>
        <p>in the latter call information about events is recovered in <code><span
              style="font-size:10.0pt">sol.te,sol.ye,sol.ie</span></code>.<o:p></o:p></p>
        <ul type="disc">
          <li class="MsoNormal"
            style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l6
            level1 lfo5">
            support of complex solution with detection of complexity in
            <code><span style="font-size:10.0pt">y0</span></code> or
            <code><span style="font-size:10.0pt">f(t0,y0)</span></code>,
            e.g.<o:p></o:p></li>
        </ul>
        <pre><span class="line">function out = crhs(t,y)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">    out = 10*exp(2*%i*%pi*t)*y;</span><code><o:p></o:p></code></pre>
        <pre><span class="line">end</span><code><o:p></o:p></code></pre>
        <pre><span class="line">[t,y] = cvode_solve(crhs, [0,5], 1)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">plot(t,real(y),t,imag(y))</span><o:p></o:p></pre>
        <ul type="disc">
          <li class="MsoNormal"
            style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l2
            level1 lfo6">
            Support of a callback function called after each successfull
            step, giving access to current solver statistics and
            allowing to stop integration (e.g. by a "stop" button on a
            GUI), e.g.<o:p></o:p></li>
        </ul>
        <pre><span class="line">function stop = scicallback(t,y,flag,stats)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">    stop = %f</span><code><o:p></o:p></code></pre>
        <pre><span class="line">    if flag == "step"</span><code><o:p></o:p></code></pre>
        <pre><span class="line">        mprintf("%s : hlast=%g\n", flag, stats.hlast)</span><code><o:p></o:p></code></pre>
        <pre><span class="line">    end</span><code><o:p></o:p></code></pre>
        <pre><span class="line">end</span><code><o:p></o:p></code></pre>
        <pre><span class="line">[t,y] = cvode_solve(f, tspan, y0, intcb=scicallback);</span><o:p></o:p></pre>
        <ul type="disc">
          <li class="MsoNormal"
            style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l1
            level1 lfo7">
            support of an arbitrary number of dimensions of ode state<o:p></o:p></li>
        </ul>
        <h2>Performance<o:p></o:p></h2>
        <p><code><span style="font-size:10.0pt">cvode_solve()</span></code>
          is roughly two times faster than
          <code><span style="font-size:10.0pt">ode()</span></code> for
          both fixed methods (Adams and BDF). As
          <code><span style="font-size:10.0pt">ode()</span></code>
          already did, compiled and dynamically linked C,C++ or Fortran
          externals are supported by
          <code><span style="font-size:10.0pt">cvode_solve()</span></code>.
          When using such externals instead of Scilab functions
          <code><span style="font-size:10.0pt">cvode_solve()</span></code>
          is generally an order of magnitude faster.<o:p></o:p></p>
        <pre>-- <o:p></o:p></pre>
        <pre>Stéphane Mottelet<o:p></o:p></pre>
        <pre>Ingénieur de recherche<o:p></o:p></pre>
        <pre>EA 4297 Transformations Intégrées de la Matière Renouvelable<o:p></o:p></pre>
        <pre>Département Génie des Procédés Industriels<o:p></o:p></pre>
        <pre>Sorbonne Universités - Université de Technologie de Compiègne<o:p></o:p></pre>
        <pre>CS 60319, 60203 Compiègne cedex<o:p></o:p></pre>
        <pre>Tel : +33(0)344234688<o:p></o:p></pre>
        <pre><a href="https://antispam.utc.fr/proxy/v3?i=WjB4M1dJWGJJMnNGTHV5MuAPDwEdQko7KGyaWIIeme0&r=Skk2OVhvdXl2cm1uOWJtRLRPDrgr4YiCABksjbHu_Gv8eNkcUiMzd6MxV8KbAPI5&f=M2FwZHlGNnU1aUlkc09ZNN6FtQAZUfRagBYPQiUfaoT45ZkXHKKVm0cOGvv2yMCS&u=http%3A//www.utc.fr/~mottelet&k=CXOq" moz-do-not-send="true">http://www.utc.fr/~mottelet</a><o:p></o:p></pre>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/v3?i=WjB4M1dJWGJJMnNGTHV5MuAPDwEdQko7KGyaWIIeme0&r=Skk2OVhvdXl2cm1uOWJtRLRPDrgr4YiCABksjbHu_Gv8eNkcUiMzd6MxV8KbAPI5&f=M2FwZHlGNnU1aUlkc09ZNN6FtQAZUfRagBYPQiUfaoT45ZkXHKKVm0cOGvv2yMCS&u=http%3A//lists.scilab.org/mailman/listinfo/users&k=CXOq">https://antispam.utc.fr/proxy/v3?i=WjB4M1dJWGJJMnNGTHV5MuAPDwEdQko7KGyaWIIeme0&r=Skk2OVhvdXl2cm1uOWJtRLRPDrgr4YiCABksjbHu_Gv8eNkcUiMzd6MxV8KbAPI5&f=M2FwZHlGNnU1aUlkc09ZNN6FtQAZUfRagBYPQiUfaoT45ZkXHKKVm0cOGvv2yMCS&u=http%3A//lists.scilab.org/mailman/listinfo/users&k=CXOq</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
<a class="moz-txt-link-freetext" href="http://www.utc.fr/~mottelet">http://www.utc.fr/~mottelet</a>
</pre>
  </body>
</html>