
4 Analysis of Example Truss by a CAS 4–1 Chapter 4: ANALYSIS OF EXAMPLE TRUSS BY A CAS TABLE OF CONTENTS Page §4.1 Computer Algebra Systems ................ 4–3 §4.1.1 Why Mathematica? ............... 4–3 §4.1.2 How to Get It ................. 4–3 §4.1.3 Programming Style and Prerequisites ......... 4–4 §4.1.4 Class Demo Scripts ............... 4–5 §4.2 Program Organization ................. 4–6 §4.3 The Element Stiffness Module ............... 4–7 §4.3.1 Module Description ............... 4–7 §4.3.2 Programming Remarks .............. 4–8 §4.3.3 Case Sensitivity ................ 4–9 §4.3.4 Testing the Member Stiffness Module ......... 4–9 §4.4 Merging a Member into the Master Stiffness ......... 4–9 §4.5 Assembling the Master Stiffness .............. 4–11 §4.6 Modifying the Master System .............. 4–11 §4.7 Recovering Internal Forces ................ 4–13 §4.8 Putting the Pieces Together ............... 4–14 §4.8.1 The Driver Script ................ 4–14 §4.8.2 Is All of This Worthwhile? ............ 4–15 §4. Notes and Bibliography ................. 4–17 §4. References ..................... 4–17 §4. Exercises ...................... 4–18 4–2 §4.1 COMPUTER ALGEBRA SYSTEMS §4.1. Computer Algebra Systems Computer algebra systems, known by the acronym CAS, are programs designed to perform sym- bolic and numeric manipulations following the rules of mathematics.1 The development of such programs began in the mid 1960s. The first comprehensive system — the “granddaddy” of them all, called Macsyma (an acronym for Project Mac Symbolic Manipulator) — was developed using the programming language Lisp at MIT’s famous Artificial Intelligence Laboratory over the period 1967 to 1980. The number and quality of symbolic-manipulation programs has expanded dramatically since the availability of graphical workstations and personal computers has encouraged interactive and ex- perimental programming. As of this writing the leading general-purpose contenders are Maple and Mathematica.2 In addition there are a dozen or so more specialized programs, some of which are available free or at very reasonable cost. See Notes and Bibliography at the end of the Chapter. §4.1.1. Why Mathematica? In the present book Mathematica will be used for Chapters and Exercises that develop symbolic and numerical computation for matrix structural analysis and FEM implementations. Mathematica is a commercial product developed by Wolfram Research, web site: http://www.wolfram.com. The version used to construct the code fragments presented in this Chapter is 4.1, which was commercially released in 2001. (Update: The latest version is 8, released in 2011.) The main advantages of Mathematica for technical computing are: 1. Availability on a wide range of platforms that range from PCs and Macs through Unix work- stations. At CU Boulder, it is available through a free campus license (see §4.1). 2. Up-to-date user interface. On all machines Mathematica offers a graphics user interface called the Notebook front-end. This is mandatory for serious work. It provides professional typesetting for results. 3. A powerful programming language. 4. Good documentation and abundance of application books at all levels. One common disadvantage of CAS, and Mathematica is no exception, is computational inefficiency in numerical calculations compared with a low-level implementation in, for instance, C or Fortran. The relative penalty can reach several orders of magnitude. For instructional use, however, the penalty is acceptable when compared to human efficiency. This means the ability to get FEM programs up and running in very short time, with capabilities for symbolic manipulation and graphics as a bonus. 1 Some CAS vendors call that kind of activity “doing mathematics by computer.” It is more appropriate to regard such programs as enabling tools that help humans with complicated and error-prone manipulations. Mettle and metal. As of now, only humans can do mathematics. 2 Another commonly used program for engineering computations: Matlab, does only numerical computations although a [poorly done] interface to Maple can be purchased as a toolbox. Historical notes: Macsyma died as a commercial product in 1999, although the Lisp source code of some versions is freely available. The Maple developer company Waterloo Maple Inc., also known as Maplesoft, was purchased in 2009 by the Japanese software retailer Cybernet Systems. As a result, the Matlab symbolic toolbox is likely to be replaced. 4–3 Chapter 4: ANALYSIS OF EXAMPLE TRUSS BY A CAS Eligibility: students, faculty, staff and departments of all CU campuses Platforms: Mac OSX, Windows, Linux, Solaris, AIX, HP-UX How to Get It 1) Download and install software as per instructions at http://oit.colorado.edu/software-hardware/site-licenses/mathematica or request an installation CD from the Site Licensing office: [email protected], 303-492-8995 2) Register your copy online at http://register.wolfram.com/ using campus license number L2437-5121 plus your computer MathID number. Be sure to use your CU mail address. 3) A password (unique to your computer) will be forwarded to you via email from Site Licensing ITS Support Question & tech support problems: send email to [email protected] Periodic hands-on workshops are available for those new to the software, click on Workshops on the Web page given above. Details (for example: what is a MathID?) about licensing & support are posted at the above web site. Figure 4.1. Instructions to get Mathematica for free from CU-OIT (Office of Information Technology). One correction: the CD version is no longer available. §4.1.2. How to Get It Starting 1 August 2007, a free one-year license from CU’s Information Technology Services (ITS) is available. Students may renew this license as long as they are registered. See Figure 4.1 for the “How to Get It” instructions. If you plan to keep Mathematica for a longer time, an academic version is available.3 One word of caution about the campus-licensed free copy: once installed on your laptop or desktop, it cannot be transferred to another computer since the license is forever keyed to the disk identification. (For example, it won’t launch if the disk is erased or replaced.) §4.1.3. Programming Style and Prerequisites The following material assumes that you are a moderately experienced user of Mathematica,or are willing to learn to be one. See Notes and Bibliography for a brief discussion of tutorial and reference materials in case you are interested. The best way to learn it from scratch is trying it as a calculator and using online help as needed. Practice with the program until you reach the level of writing functions, modules and scripts with relative ease. With the Notebook interface and a good primer it takes only a few hours. When approaching that level you may notice that functions in Mathematica display many aspects similar 3 This was written in 2001; this option does not seem to exist anymore. 4–4 §4.1 COMPUTER ALGEBRA SYSTEMS to C.4 You can exploit this similarity if you are proficient in that language. But Mathematica functions do have some unique aspects, such as matching arguments by pattern, and the fact that internal variables are global unless otherwise made local.5 Modification of function arguments should be avoided because it may be difficult to trace side effects. The programming style enforced here outlaws output arguments and a function can only return its name. But since the name can be a list of arbitrary objects the restriction is not serious.6 Our objective is to develop a symbolic program written in Mathematica that solves the example plane truss as well as some symbolic versions thereof. The program will rely heavily on the development and use of functions implemented using the Module construct of Mathematica. Thus the style will be one of procedural programming.7 The program will not be particularly modular (in the computer science sense) because Mathematica is not suitable for that programming style.8 The code presented in §4.2 through §4.8 uses a few language constructs that may be deemed as advanced, and these are briefly noted in the text so that appropriate reference to the Mathematica reference manual can be made. §4.1.4. Class Demo Scripts The cell scripts shown in Figures 4.2 and 4.3 will be used to illustrate the organization of a Note- book file and the “look and feel” of some basic Mathematica commands. These scripts will be demonstrated in class from a laptop. 4 Simple functions can be implemented in Mathematica directly, for instance DotProduct[x ,y ]:=x.y; more com- plicated functions are handled by the Module construct. These constructs are called rules by computer scientists. 5 In Mathematica everything is a function, including programming constructs. Example: in C for is a loop-opening keyword, whereas in Mathematica For is a function that runs a loop according to its arguments. 6 Such restrictions on arguments and function returns are closer in spirit to C than Fortran although you can of course modify C-function arguments using pointers — exceedingly dangerous but often unavoidable. 7 The name Module should not be taken too seriously: it is far away from the concept of modules in Ada, Modula, Oberon or Fortran 90. But such precise levels of interface control are rarely needed in symbolic languages. 8 Indeed none of the CAS packages in popular use is designed for strong modularity because of historical and interactivity constraints. 4–5 Chapter 4: ANALYSIS OF EXAMPLE TRUSS BY A CAS Integration example f[x_,α_,β_]:=(1+β*x^2)/(1+α*x+x^2); F=Integrate[f[x,-1,2],{x,0,5}]; F=Simplify[F]; Print[F]; Print[N[F]]; F=NIntegrate[f[x,-1,2],{x,0,5}]; Print["F=",F//InputForm]; 10 + Log[21] 13.0445 F=13.044522437723455 Figure 4.2.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages19 Page
-
File Size-