• No results found

Proceedings of the asmeconf International Examples Congress and Exposition AIECE21 January 20, 2021, Cambridge, MA

N/A
N/A
Protected

Academic year: 2021

Share "Proceedings of the asmeconf International Examples Congress and Exposition AIECE21 January 20, 2021, Cambridge, MA"

Copied!
2
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Proceedings of the asmeconf International Examples Congress and Exposition AIECE21 January 20, 2021, Cambridge, MA

AIECE2021-0001

EXAMPLE OF LuaL

A

TEX WITH ASMECONF.CLS FOR ODE INTEGRATION

John H. Lienhard V

1,

1

Massachusetts Institute of Technology, Cambridge, MA

ABSTRACT

This paper is an example of using asmeconf with LuaL

A

TEX to solve an ODE initial value problem using a fourth-order Runge- Kutta method and to plot the result using PGFPLOTS. The use of a landscape figure is also illustrated. References are given for further reading.

Keywords: asmeconf, LuaL

A

TEX, ODE, pgfplots, landscape

NOMENCLATURE

𝐴 Constant parameter [–]

𝑡 Time [s]

𝑦 (𝑡) Position [m]

1. INTRODUCTION

LuaL

A

TEX is built upon the Lua programming language [ 1].

By directly using Lua code in a L

A

TEX file, we can accomplish a wide range of tasks, as illustrated in the open-access paper by Montijano et al. [2]. In the present example, we follow Monti- jano et al. in solving a nonlinear first-order ordinary differential equation and plotting the result—all within a single L

A

TEX file!

2. SOLUTION TO AN INITIAL VALUE PROBLEM

We consider an initial value problem like that of Montijano et al.:

𝑦

0

(𝑡) = 𝐴 · 𝑦(𝑡) cos  𝑡 + p

1 + 𝑦(𝑡) 

with 𝑦(0) = 1 (1)

Here, 𝐴 is a constant. We may adopt a fourth-order Runge-Kutta algorithm for the integration, which we shall perform to 𝑡 = 30 s using a 400 point discretization. The details of the Runge-Kutta algorithm and a listing of the code are given in Montijano et al.

(You can also read the code in the present .tex file.)

The algorithm is implemented directly in the preamble of this file, and the results are plotted in Fig. 1 for 𝐴 = {0.25, 0.5, 0.75, 1.0}. Plotting is done using the PGFPLOTS pack- age [3].

∗Corresponding author: lienhard@mit.edu Version 1.0, January 18, 2021

Landscape figures, such as Fig. 1, may be produced at full- page size by putting \usepackage[figuresright]{rotating}

in your .tex file’s preamble and using the sidewaysfigure*

environment [4].

3. CONCLUSION

LuaL

A

TEX enables numerical computations within a L

A

TEX environment. By combining this capability with PGFPlots, the need for separate numerical and/or graphics packages can be reduced.

ACKNOWLEDGMENTS

The example shown in this paper is directly based on an example given by Montijano et al. [2]. Additional examples, such as the Lorenz attractor, are contained in that paper.

REFERENCES

[1] lerusalimschy, Roberto, de Figueiredo, Luiz Henrique and Celes, Waldemar. Lua 5.3 Reference Manual. Pontifical Catholic University, Rio de Janeiro, Brazil (2017). URL https://www.lua.org/manual/5.3/.

[2] Montijano, Juan I., Pérez, Mario, Rández, Luis and Varona, Juan Luis. “Numerical methods with LuaL

A

TEX.” TUG- boat Vol. 35 No. 1 (2014): pp. 51–56. URL https://tug.org/

TUGboat/tb35-1/tb109montijano.pdf. Open access.

[3] Feuersänger, Christian. Manual for Package PGFPLOTS, Version 1.17. Comprehensive TEX Archive Network (2020). Accessed January 4, 2021, URL https://ctan.org/

pkg/pgfplots.

[4] Fairbairns, Robin, Rahtz, Sebastian and Barroca, Leonor. “A Package for Rotated Objects in L

A

TEX.” Version 2.16d. Com- prehensive TEX Archive Network (2016). Accessed October 2, 2019, URL https://www.ctan.org/pkg/rotating.

1

(2)

0 5 10 15 20 25 30 0

0 . 2

0 . 4

0 . 6

0 . 8

1 Time, t [s]

Position, y[m]

A = 0 . 25 A = 0 . 5 A = 0 . 75 A = 1 FIGURE 1: A trial of pgfplo t with L uacode Rung e-K utt a int egr ation

2

Referenties

GERELATEERDE DOCUMENTEN

The tabfigures package is a collection of patches for using tabular figures in some LaTeX environments where numbers should line up vertically such as the table of contents

When you increase the number of columns on a page, you usually need to change the font size (for three columns, I switched to the cmss8 font— it seemed to work out OK because the

typeset a right to left text with its translation on the facing page 1.. As you can see, the switch to RTL convention is made before

This file provides an example of how to use reledpar and LuaL A TEX to typeset a.. right to left text with its translation on the facing

These observations are supported by Gard (2008:184) who states, “While I would reject the idea of a general ‘boys crisis’, it remains true that there are many boys who

When using normalized response data, a strong inverse correlation between affective state and the runners’ forward and sideways movement characteristics is observed. The low

This is true since it is the best solution in all solution spaces cut away by the piercing cuts and the remaining part of the solution space cannot contain a better solution, since

In view of the above, the objective of this theoretical essay is to show why a pragmatic style of research may be appropriate for the teacher to use as instrument to solve