topic passing additional parameters to RHS function of ODE solver in Intel® oneAPI Math Kernel Library
https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/passing-additional-parameters-to-RHS-function-of-ODE-solver/m-p/1045530#M20935
<P>Hi,</P>
<P>I am trying to use the Intel's ODE solver to solver a system of equations. Below is the how the RHS function is supposed to be defined (from manual):</P>
<P>subroutine <name>(n, t, y, f)<BR />
integer n<BR />
double precision t, y(n), f(n)<BR />
..................<BR />
f(i) = .....<BR />
..................<BR />
return<BR />
end</P>
<P>The problem is I need to pass additional parameters to the RHS function. Is there a way to do that?</P>
<P>Thanks!</P>
<P>Bo</P>
<P> </P>Tue, 04 Nov 2014 05:07:11 GMTBo_Q_2014-11-04T05:07:11Zpassing additional parameters to RHS function of ODE solver
https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/passing-additional-parameters-to-RHS-function-of-ODE-solver/m-p/1045530#M20935
<P>Hi,</P>
<P>I am trying to use the Intel's ODE solver to solver a system of equations. Below is the how the RHS function is supposed to be defined (from manual):</P>
<P>subroutine <name>(n, t, y, f)<BR />
integer n<BR />
double precision t, y(n), f(n)<BR />
..................<BR />
f(i) = .....<BR />
..................<BR />
return<BR />
end</P>
<P>The problem is I need to pass additional parameters to the RHS function. Is there a way to do that?</P>
<P>Thanks!</P>
<P>Bo</P>
<P> </P>Tue, 04 Nov 2014 05:07:11 GMThttps://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/passing-additional-parameters-to-RHS-function-of-ODE-solver/m-p/1045530#M20935Bo_Q_2014-11-04T05:07:11ZDeclare the additional
https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/passing-additional-parameters-to-RHS-function-of-ODE-solver/m-p/1045531#M20936
<P>Declare the additional parameters and variables in a module. USE that module in the main program, and read/assign values to the module variables as needed. In the subroutine that implements the specific ODE, USE the module and access the variables as needed.</P>
<P>For example, you can modify the van der Pol example that is included with the Intel ODE solver to take a parameter K in place of 1.0d6 in the equation: y” - K * [ ( 1 - y*y ) * y’ + K * y = 0. Then, the module contains:</P>
<P> MODULE PARS_MOD<BR />
double precision :: K<BR />
END MODULE</P>
<P>Add "USE PARS_MOD" to all subprograms that need to set/get the value of K.</P>
<P>In the main program, you can do:</P>
<P> WRITE(*,'(A)',advance='no')' Enter K : '<BR />
READ (*,*) K</P>
<P>In subroutine rhs_v_d_p, change to</P>
<P> f(2)=K*((1.d0-y(1)*y(1))*y(2)-y(1))</P>
<P><SPAN style="font-size: 1em; line-height: 1.5;">and, in subroutine jacmat_v_d_p, change to</SPAN></P>
<P> a(2,1)=-K*(1.d0+2.d0*y(1)*y(2))<BR />
a(2,2)= K*(1.d0-y(1)* y(1))</P>
<P>You will probably need to deactivate all the result checks, since they use pre-computed results that are correct only for the specific case K = 1.0d6.</P>
<P> </P>Tue, 04 Nov 2014 17:18:00 GMThttps://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/passing-additional-parameters-to-RHS-function-of-ODE-solver/m-p/1045531#M20936mecej42014-11-04T17:18:00Z