📄 pendulum.xmds
字号:
<?xml version="1.0"?><!-- Example simulation: finite amplitude pendulum --><!-- $Id: pendulum.xmds,v 1.8 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. --><!-- Adapted from the exercise in "A first course in computational --><!-- physics" by Paul L. DeVries, pg 234--><!-- Try the simulation for different values of E, namely: --><!-- E = 0.25, 0.5, 0.75, 1.0, 1.25, and 1.5 --><!-- Note: this simulation can be run as a shell/Perl/Python script by --><!-- changing the value of E using the command line argument --><simulation> <name>pendulum</name> <author>Paul Cochrane</author> <description> Example simulation of a finite amplitude pendulum. Adapted fro the exercise in "A first course in computational physics" by Paul L. DeVries, page 234. </description> <!-- Global system parameters and functionality --> <prop_dim>t</prop_dim> <stochastic>no</stochastic> <!-- Global variables for the simulation --> <globals> <![CDATA[ const double g = 1.0; // acceleration due to gravity (scaled!) const double m = 0.5; // mass const double l = 1.0; // length ]]> </globals> <!-- Command line argument --> <argv> <arg> <name>E</name> <type>double</type> <default_value>0.25</default_value> </arg> </argv> <!-- Field to be integrated over --> <field> <samples>1</samples> <vector> <name>main</name> <type>double</type> <components>theta thetaDot</components> <![CDATA[ theta = 0.0; thetaDot = sqrt(2.0*E/(m*l*l)); ]]> </vector> </field> <!-- The sequence of integrations to perform --> <sequence> <integrate> <algorithm>RK4EX</algorithm> <interval>10.0</interval> <lattice>5000</lattice> <samples>50</samples> <![CDATA[ dtheta_dt = thetaDot; dthetaDot_dt = -g*sin(theta)/l; ]]> </integrate> </sequence> <!-- The output to generate --> <output format="ascii" precision="double"> <group> <sampling> <moments>t_out tDot_out KE PE</moments> <![CDATA[ t_out = theta; tDot_out = thetaDot; KE = 0.5*m*l*l*thetaDot*thetaDot; PE = m*g*l*(1.0-cos(theta)); ]]> </sampling> </group> </output></simulation>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -