ring_modulator.xmds
来自「XMDS is a code generator that integrates」· XMDS 代码 · 共 181 行
XMDS
181 行
<?xml version="1.0"?><simulation> <!-- $Id: ring_modulator.xmds,v 1.2 2004/07/14 06:37:05 joehope 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> ring_modulator </name> <!-- the name of the simulation --> <author> Paul Cochrane </author> <!-- the author of the simulation --> <description> Simulation of a ring modulator circuit in electrical analysis. The simulation describes the behaviour of the ring modulator, which, given a low-frequency signal, and a high frequency signal produces a mixed signal output. This script is adapted from the Intial Value Test Set http://www.dm.uniba.it/~testset </description> <!-- Global system parameters and functionality --> <prop_dim> t </prop_dim> <!-- name of main propagation dim --> <use_mpi> no </use_mpi> <!-- defaults to no --> <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[ const double C = 1.6e-8; const double Cs = 2e-12; const double Cp = 1e-8; const double Lh = 4.45; const double Ls1 = 0.002; const double Ls2 = 5e-4; const double Ls3 = 5e-4; const double gam = 40.67286402e-9; const double R = 25000; const double Rp = 50; const double Rg1 = 36.3; const double Rg2 = 17.3; const double Rg3 = 17.3; const double Ri = 50; const double Rc = 600; const double delta = 17.7493332; const double maxDeltaU = 172; ]]> </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> y1 y2 y3 y4 y5 y6 y7 y8 y9 y10 y11 y12 y13 y14 y15 </components> <!-- names of components --> <![CDATA[ y1 = 0; y2 = 0; y3 = 0; y4 = 0; y5 = 0; y6 = 0; y7 = 0; y8 = 0; y9 = 0; y10 = 0; y11 = 0; y12 = 0; y13 = 0; y14 = 0; y15 = 0; ]]> </vector> </field> <!-- The sequence of integrations to perform --> <sequence> <integrate> <algorithm> RK4IP </algorithm> <!-- RK4EX, RK4IP, SIEX, SIIP --> <interval> 1e-3 </interval> <!-- how far in main dim? --> <lattice> 100000000 </lattice> <!-- no. points in main dim --> <samples> 1000 </samples> <!-- no. pts in output moment group --> <![CDATA[ double Uin1 = 0.5*sin(2000*M_PI*t); double Uin2 = 2.0*sin(20000*M_PI*t); double UD1 = y3 - y5 - y7 - Uin2; double UD2 = -y4 + y6 - y7 - Uin2; double UD3 = y4 + y5 + y7 + Uin2; double UD4 = -y3 - y6 + y7 + Uin2; if ( (delta*UD1 > maxDeltaU) || (delta*UD2 > maxDeltaU) || (delta*UD3 > maxDeltaU) || (delta*UD4 > maxDeltaU) ) { printf("delta*U is greater than maxDeltaU, exiting\n"); printf("delta*UD1 = %g\tdelta*UD2 = %g\tdelta*UD3 = %g\tdelta*UD4 = %g\n", delta*UD1, delta*UD2, delta*UD3, delta*UD4); exit(255); } double qUD1 = gam*exp(delta*UD1 - 1.0); double qUD2 = gam*exp(delta*UD2 - 1.0); double qUD3 = gam*exp(delta*UD3 - 1.0); double qUD4 = gam*exp(delta*UD4 - 1.0); dy1_dt = (y8 - 0.5*y10 + 0.5*y11 + y14 - y1/R)/C; dy2_dt = (y9 - 0.5*y12 + 0.5*y13 + y15 - y2/R)/C; dy3_dt = (y10 - qUD1 + qUD4)/Cs; dy4_dt = (-y11 + qUD2 - qUD3)/Cs; dy5_dt = (y12 + qUD1 - qUD3)/Cs; dy6_dt = (-y13 - qUD2 + qUD4)/Cs; dy7_dt = (-y7/Rp + qUD1 + qUD2 - qUD3 - qUD4)/Cp; dy8_dt = -y1/Lh; dy9_dt = -y2/Lh; dy10_dt = (0.5*y1 - y3 - Rg2*y10)/Ls2; dy11_dt = (-0.5*y1 + y4 - Rg3*y11)/Ls3; dy12_dt = (0.5*y2 - y5 - Rg2*y12)/Ls2; dy13_dt = (-0.5*y2 + y6 - Rg3*y13)/Ls3; dy14_dt = (-y1 + Uin1 - (Ri + Rg1)*y14)/Ls1; dy15_dt = (-y2 - (Rc + Rg1)*y15)/Ls1; ]]> </integrate> </sequence> <!-- The output to generate --> <output format="ascii" precision="single"> <group> <sampling> <moments> y1Out y2Out y3Out y4Out y5Out y6Out y7Out y8Out y9Out y10Out y11Out y12Out y13Out y14Out y15Out </moments> <!-- names of moments --> <![CDATA[ y1Out = y1; y2Out = y2; y3Out = y3; y4Out = y4; y5Out = y5; y6Out = y6; y7Out = y7; y8Out = y8; y9Out = y9; y10Out = y10; y11Out = y11; y12Out = y12; y13Out = y13; y14Out = y14; y15Out = y15; ]]> </sampling> </group> </output> </simulation>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?