branch.xmds

来自「XMDS is a code generator that integrates」· XMDS 代码 · 共 124 行

XMDS
124
字号
<?xml version="1.0"?><simulation>  <!-- $Id: branch.xmds,v 1.1 2004/06/22 10:16:27 paultcochrane Exp $ --><!--  Copyright (C) 2000-2004                                           --><!--                                                                    --><!--  Code contributed by Greg Collecutt, Joseph Hope and Paul Cochrane --><!--                                                                    --><!--  This file is part of xmds.                                        --><!--                                                                    --><!--  This program is free software; you can redistribute it and/or     --><!--  modify it under the terms of the GNU General Public License       --><!--  as published by the Free Software Foundation; either version 2    --><!--  of the License, or (at your option) any later version.            --><!--                                                                    --><!--  This program is distributed in the hope that it will be useful,   --><!--  but WITHOUT ANY WARRANTY; without even the implied warranty of    --><!--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     --><!--  GNU General Public License for more details.                      --><!--                                                                    --><!--  You should have received a copy of the GNU General Public License --><!--  along with this program; if not, write to the Free Software       --><!--  Foundation, Inc., 59 Temple Place - Suite 330, Boston,            --><!--  MA  02111-1307, USA.                                              -->  <name> branch </name>      <!-- the name of the simulation -->    <author> Paul Cochrane </author>  <!-- the author of the simulation -->  <description>    <!-- a description of what the simulation is supposed to do -->    Branching reaction example of reaction between hydrogen and oxygen    2H_2(g) + O_2(g) -> 2 H_2O(g)    Adapted for xmds from "Mathematica computer programs for physical    chemistry", William H. Cropper, Springer Verlag (1998)    Equations are:      d[H]_dt = -k1[O_2][H] + k2[H_2][O] + k3[H_2][OH]      d[OH]_dt = k1[O_2][h] + k2[H_2][O] - k3[H_2][OH]      d[O]_dt = k1[O_2][H] - k2[H_2][O]      d[H_2]_dt = -k2[H_2][O] - k3[H_2][OH]      d[O_2]_dt = -k1[O_2][H]  </description>    <!-- Global system parameters and functionality -->  <prop_dim> t </prop_dim>    <!-- name of main propagation dim -->    <error_check> yes </error_check>   <!-- defaults to yes -->  <use_wisdom> yes </use_wisdom>     <!-- defaults to no -->  <benchmark> yes </benchmark>       <!-- defaults to no -->  <use_prefs> yes </use_prefs>       <!-- defaults to yes -->    <!-- Global variables for the simulation -->  <globals>  <![CDATA[    // reaction parameters    const double T = 800;   // temperature (in K)    const double R = 8.3145; // gas constant (in J/K/mol)    // rate constants (in L/mol/microsecond)    double k1 = 2.29e5*exp(-70000/(R*T));    double k2 = 2.89e4*exp(-42000/(R*T));    double k3 = 2.53e4*exp(-22000/(R*T));    // initial concentrations (in mol/L)    const double Ho = 1e-6;    const double O2o = 0.01;    const double OHo = 0.0;    const double Oo = 0.0;    const double H2o = 0.02;  ]]>  </globals>    <!-- Field to be integrated over -->  <field>    <name> main </name>    <samples> 1 </samples>       <!-- sample 1st point of dim? -->        <vector>      <name> main </name>      <type> double </type>           <!-- data type of vector -->      <components> H O2 OH O H2 </components>       <!-- names of components -->      <![CDATA[        H = Ho;	O2 = O2o;	OH = OHo;	O = Oo;	H2 = H2o;      ]]>    </vector>  </field>    <!-- The sequence of integrations to perform -->  <sequence>    <integrate>      <algorithm> RK4IP </algorithm> <!-- RK4EX, RK4IP, SIEX, SIIP -->      <interval> 150 </interval>   <!-- how far in main dim? -->      <lattice> 100000 </lattice>     <!-- no. points in main dim -->      <samples> 1000 </samples> <!-- no. pts in output moment group -->      <![CDATA[        dH_dt =  -k1*O2*H + k2*H2*O + k3*H2*OH;	dOH_dt =  k1*O2*H + k2*H2*O - k3*H2*OH;	dO_dt =   k1*O2*H - k2*H2*O;	dH2_dt =           -k2*H2*O - k3*H2*OH;	dO2_dt = -k1*O2*H;      ]]>    </integrate>  </sequence>    <!-- The output to generate -->  <output format="ascii">    <group>      <sampling>        <moments> Hout Oout OHout O2out H2out </moments>           <!-- names of moments -->        <![CDATA[          Hout = H/1e-4;	  Oout = O/1e-4;	  OHout = OH/1e-4;	  O2out = O2/1e-4;	  H2out = H2/1e-4;        ]]>      </sampling>    </group>  </output>  </simulation>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?