/[ascend]/trunk/doc/howto-units.lyx
ViewVC logotype

Contents of /trunk/doc/howto-units.lyx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2785 - (show annotations) (download) (as text)
Mon Jun 23 08:17:49 2014 UTC (10 years, 5 months ago) by jpye
File MIME type: application/x-lyx
File size: 16632 byte(s)
updating RPM spec for Fed20
1 #LyX 2.1 created this file. For more info see http://www.lyx.org/
2 \lyxformat 474
3 \begin_document
4 \begin_header
5 \textclass book
6 \use_default_options false
7 \maintain_unincluded_children false
8 \language english
9 \language_package default
10 \inputencoding auto
11 \fontencoding global
12 \font_roman default
13 \font_sans default
14 \font_typewriter default
15 \font_math auto
16 \font_default_family default
17 \use_non_tex_fonts false
18 \font_sc false
19 \font_osf false
20 \font_sf_scale 100
21 \font_tt_scale 100
22 \graphics default
23 \default_output_format default
24 \output_sync 0
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
28 \spacing single
29 \use_hyperref false
30 \papersize default
31 \use_geometry false
32 \use_package amsmath 2
33 \use_package amssymb 2
34 \use_package cancel 1
35 \use_package esint 0
36 \use_package mathdots 0
37 \use_package mathtools 1
38 \use_package mhchem 0
39 \use_package stackrel 1
40 \use_package stmaryrd 1
41 \use_package undertilde 1
42 \cite_engine basic
43 \cite_engine_type default
44 \biblio_style plain
45 \use_bibtopic false
46 \use_indices false
47 \paperorientation portrait
48 \suppress_date false
49 \justification true
50 \use_refstyle 0
51 \index Index
52 \shortcut idx
53 \color #008000
54 \end_index
55 \secnumdepth 3
56 \tocdepth 3
57 \paragraph_separation indent
58 \paragraph_indentation default
59 \quotes_language english
60 \papercolumns 1
61 \papersides 1
62 \paperpagestyle default
63 \tracking_changes false
64 \output_changes false
65 \html_math_output 0
66 \html_css_as_file 0
67 \html_be_strict false
68 \end_header
69
70 \begin_body
71
72 \begin_layout Chapter
73 Defining New Units of Measure
74 \begin_inset CommandInset label
75 LatexCommand label
76 name "cha:units"
77
78 \end_inset
79
80
81 \end_layout
82
83 \begin_layout Standard
84 Occasionally units of measure are needed that do not come predefined in
85 the ASCEND system.
86 You can define a new unit of measure by defining the conversion factor.
87 In this chapter, we examine how to do this easily for an individual user
88 and on a system-wide basis.
89
90 \end_layout
91
92 \begin_layout Section
93
94 \emph on
95 Caveats
96 \end_layout
97
98 \begin_layout Standard
99 \begin_inset Marginal
100 status collapsed
101
102 \begin_layout Plain Layout
103 Order matters!
104 \end_layout
105
106 \end_inset
107
108 Order matters for defining units of measure in three ways.
109 \end_layout
110
111 \begin_layout Itemize
112 a unit of measure must be defined before it is used anywhere.
113 \end_layout
114
115 \begin_layout Itemize
116 the first definition ASCEND reads for a unit of measure is the only definition
117 ASCEND sees.
118 \end_layout
119
120 \begin_layout Itemize
121 new units can be defined only from already defined units.
122 \end_layout
123
124 \begin_layout Standard
125 Measuring units are absolutely global in the ASCEND environment -- they
126 are not deleted when the Library of types is deleted.
127 Once you define a unit's conversion factor, you are stuck with it until
128 you shut down and restart ASCEND.
129 For any unit conversion definition, only the first conversion factor seen
130 is accepted.
131 Redefinitions of the same unit are ignored.
132 \end_layout
133
134 \begin_layout Standard
135 \begin_inset Marginal
136 status collapsed
137
138 \begin_layout Plain Layout
139 Multiplicative unit conversions only!
140 \end_layout
141
142 \end_inset
143
144 The various units ASCEND uses are all obtained by conversion factors (multiplica
145 tion only) from the SI units.
146 So, for example, temperatures may be in degrees Rankine but not in Fahrenheit.
147 In this chapter we address creating new conversion factors.
148 For handling non-
149 \end_layout
150
151 \begin_layout Standard
152 multiplicative conversions (such as the Fahrenheit or Celsius offsets) see
153 Section
154 \begin_inset space ~
155 \end_inset
156
157
158 \begin_inset CommandInset ref
159 LatexCommand vref
160 reference "sec:dimeqns.Fahrenheit"
161
162 \end_inset
163
164 .
165 \end_layout
166
167 \begin_layout Section
168 Individualised units
169 \end_layout
170
171 \begin_layout Standard
172 There are two scenarios for individualized units of measure.
173 One in which you need a measure defined only for a specific model and another
174 in which you want to define a measure that you will use throughout your
175 modeling activities in the future.
176 The syntax for both is the same, but where best to put the UNITS statement
177 differs.
178 \end_layout
179
180 \begin_layout Subsection
181 Units of measure for a specific model
182 \end_layout
183
184 \begin_layout Standard
185 Units of measure that are used in only one model can be defined at the beginning
186 of the model itself or before the model, but not the units appear in the
187 model definition.
188 Let us suppose you want to measure speed in {furlong/fortnight} in a model.
189 ASCEND does not define
190 \family typewriter
191 furlong
192 \family default
193 ,
194 \family typewriter
195 fortnight
196 \family default
197 , or
198 \family typewriter
199 furlong/fortnight
200 \family default
201 .
202 (Interestingly, we have been unable to find standard definitions for them!).
203 \end_layout
204
205 \begin_layout LyX-Code
206 MODEL mock_turtle;
207 \end_layout
208
209 \begin_layout LyX-Code
210 d IS_A distance;
211 \end_layout
212
213 \begin_layout LyX-Code
214 delta_t IS_A time;
215 \end_layout
216
217 \begin_layout LyX-Code
218 s IS_A speed
219 \end_layout
220
221 \begin_layout LyX-Code
222
223 \end_layout
224
225 \begin_layout LyX-Code
226 s = d/delta_t;
227 \end_layout
228
229 \begin_layout LyX-Code
230 (* We really should write s * delta_t = d;
231 \end_layout
232
233 \begin_layout LyX-Code
234 to avoid division by zero.
235 *)
236 \end_layout
237
238 \begin_layout LyX-Code
239
240 \end_layout
241
242 \begin_layout LyX-Code
243 UNITS
244 \end_layout
245
246 \begin_layout LyX-Code
247 furlong = {3.17*kilometer};
248 \end_layout
249
250 \begin_layout LyX-Code
251 fortnight = {10*day};
252 \end_layout
253
254 \begin_layout LyX-Code
255 END UNITS;
256 \end_layout
257
258 \begin_layout LyX-Code
259
260 \end_layout
261
262 \begin_layout LyX-Code
263 METHODS
264 \end_layout
265
266 \begin_layout LyX-Code
267 METHOD default_self;
268 \end_layout
269
270 \begin_layout LyX-Code
271 d := 1 {furlong};
272 \end_layout
273
274 \begin_layout LyX-Code
275 t := 5 {hours};
276 \end_layout
277
278 \begin_layout LyX-Code
279 END default_self;
280 \end_layout
281
282 \begin_layout LyX-Code
283
284 \end_layout
285
286 \begin_layout LyX-Code
287 (* other standard methods omitted *)
288 \end_layout
289
290 \begin_layout LyX-Code
291
292 \end_layout
293
294 \begin_layout LyX-Code
295 END mock_turtle;
296 \end_layout
297
298 \begin_layout Standard
299 In mock_turtle we define
300 \family typewriter
301 furlong
302 \family default
303 and
304 \family typewriter
305 fortnight
306 \family default
307 conversions
308 \series bold
309 before
310 \series default
311 they are used in the methods and before any equations which use them.
312 Also, notice that, even though ASCEND rejects this model
313 \family typewriter
314 mock_turtle
315 \family default
316 , as it will because of the missing "
317 \family typewriter
318 ;
319 \family default
320 " after "speed" in the fourth line,
321 \family typewriter
322 furlong
323 \family default
324 and
325 \family typewriter
326 fortnight
327 \family default
328 still get defined.
329 The
330 \family typewriter
331 UNITS
332 \family default
333 statement can appear in any context and gets processed regardless of any
334 other errors in that context.
335 \end_layout
336
337 \begin_layout Subsection
338 UNITS OF MEASURE FOR ALL YOUR PERSONAL MODELS
339 \end_layout
340
341 \begin_layout Standard
342 If you commonly use a set of units that is not in the default ASCEND library
343
344 \family typewriter
345 measures.a4l
346 \family default
347 , you can create your own personal library of units in the user data directory
348
349 \family typewriter
350 ascdata
351 \family default
352 .
353 The location of this directory is given by ASCEND at the end of all the
354 start-up spew it prints to the Console window (or xterm under UNIX) as
355 shown below.
356 You will see a path other than
357 \family typewriter
358 /usr0/ballan/
359 \family default
360 of course.
361 \end_layout
362
363 \begin_layout LyX-Code
364 -----------------------------------
365 \end_layout
366
367 \begin_layout LyX-Code
368 User data directory is /usr0/ballan/ascdata
369 \end_layout
370
371 \begin_layout LyX-Code
372 -----------------------------------
373 \end_layout
374
375 \begin_layout Standard
376 Create the library file
377 \family typewriter
378 myunits.a4l
379 \family default
380 in your
381 \family typewriter
382 ascdata
383 \family default
384 directory.
385 This file should contain a
386 \family typewriter
387 UNITS
388 \family default
389 statement and any comments or
390 \family typewriter
391 NOTES
392 \family default
393 you wish to make.
394 This file should contain any conversions that you change often.
395 For example:
396 \end_layout
397
398 \begin_layout LyX-Code
399 UNITS
400 \end_layout
401
402 \begin_layout LyX-Code
403 (* Units for Norway, maybe?*)
404 \end_layout
405
406 \begin_layout LyX-Code
407 euro = {1*currency};
408 \end_layout
409
410 \begin_layout LyX-Code
411 (* currency is the fundamental financial unit *)
412 \end_layout
413
414 \begin_layout LyX-Code
415 kroner = {0.00314*euro};
416 \end_layout
417
418 \begin_layout LyX-Code
419 nk = {kroner};
420 \end_layout
421
422 \begin_layout LyX-Code
423 USdollar = {0.9*euro};
424 \end_layout
425
426 \begin_layout LyX-Code
427 CANdollar = {0.65*USdollar};
428 \end_layout
429
430 \begin_layout LyX-Code
431 END UNITS;
432 \end_layout
433
434 \begin_layout Standard
435 Note that this file contains a definition of
436 \family typewriter
437 USdollar
438 \family default
439 different from that given in the standard library
440 \family typewriter
441 measures.a4l
442 \family default
443 .
444 ASCEND will warn you about the conflict.
445 You must load
446 \family typewriter
447 myunits.a4l
448 \family default
449 into ASCEND before
450 \family typewriter
451 atoms.a4l
452 \family default
453 or any of our higher level libraries.
454 You can ensure that this happens by putting the statement
455 \end_layout
456
457 \begin_layout LyX-Code
458 REQUIRE "myunits.a4l";
459 \end_layout
460
461 \begin_layout Standard
462 on the very first line in all your model definition files.
463 \end_layout
464
465 \begin_layout Section
466 NEW SYSTEM-WIDE UNITS
467 \end_layout
468
469 \begin_layout Standard
470 Suppose you are maintaining ASCEND on a network of computers with many users.
471 You have a standard set of models stored in a centrally located directory,
472 and you want to define units for use by everyone on the network.
473 In this case, just edit
474 \family typewriter
475 models/measures.a4l
476 \family default
477 , the default units of measure library.
478 ASCEND is an open system.
479
480 \end_layout
481
482 \begin_layout Standard
483 Make the new unit conversion definition statement(s) of the form
484 \end_layout
485
486 \begin_layout LyX-Code
487 newunit = {combination of old units};
488 \end_layout
489
490 \begin_layout Standard
491 as described in **Section 9.2.** In the file
492 \family typewriter
493 measures.a4l
494 \family default
495 , add your statement(s) anywhere inside the block of definitions that starts
496 with
497 \family typewriter
498 UNITS
499 \family default
500 and ends with
501 \family typewriter
502 END UNITS
503 \family default
504 .
505 The existing definitions are divided up into groups by comment statements.
506 If your conversion belongs to one of the groups, it is best to put the
507 conversion in that group.
508 The groups are given in Table
509 \begin_inset CommandInset ref
510 LatexCommand ref
511 reference "tab:units.groupOfUnits"
512
513 \end_inset
514
515 .
516 \end_layout
517
518 \begin_layout Standard
519 \begin_inset Float table
520 wide false
521 sideways false
522 status open
523
524 \begin_layout Plain Layout
525 \begin_inset Caption Standard
526
527 \begin_layout Plain Layout
528 Groups of units in the current measures library
529 \begin_inset CommandInset label
530 LatexCommand label
531 name "tab:units.groupOfUnits"
532
533 \end_inset
534
535
536 \end_layout
537
538 \end_inset
539
540
541 \end_layout
542
543 \begin_layout Plain Layout
544 \begin_inset Tabular
545 <lyxtabular version="3" rows="21" columns="1">
546 <features rotate="0" tabularvalignment="middle">
547 <column alignment="center" valignment="top">
548 <row>
549 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
550 \begin_inset Text
551
552 \begin_layout Plain Layout
553
554 \family typewriter
555 distance
556 \end_layout
557
558 \end_inset
559 </cell>
560 </row>
561 <row>
562 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
563 \begin_inset Text
564
565 \begin_layout Plain Layout
566
567 \family typewriter
568 mass
569 \end_layout
570
571 \end_inset
572 </cell>
573 </row>
574 <row>
575 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
576 \begin_inset Text
577
578 \begin_layout Plain Layout
579
580 \family typewriter
581 time
582 \end_layout
583
584 \end_inset
585 </cell>
586 </row>
587 <row endhead="true">
588 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
589 \begin_inset Text
590
591 \begin_layout Plain Layout
592
593 \family typewriter
594 molecular quantities
595 \end_layout
596
597 \end_inset
598 </cell>
599 </row>
600 <row endhead="true">
601 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
602 \begin_inset Text
603
604 \begin_layout Plain Layout
605
606 \family typewriter
607 money
608 \end_layout
609
610 \end_inset
611 </cell>
612 </row>
613 <row endhead="true">
614 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
615 \begin_inset Text
616
617 \begin_layout Plain Layout
618
619 \family typewriter
620 reciprocal time (frequency)
621 \end_layout
622
623 \end_inset
624 </cell>
625 </row>
626 <row endhead="true">
627 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
628 \begin_inset Text
629
630 \begin_layout Plain Layout
631
632 \family typewriter
633 area
634 \end_layout
635
636 \end_inset
637 </cell>
638 </row>
639 <row endhead="true">
640 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
641 \begin_inset Text
642
643 \begin_layout Plain Layout
644
645 \family typewriter
646 volume
647 \end_layout
648
649 \end_inset
650 </cell>
651 </row>
652 <row endhead="true">
653 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
654 \begin_inset Text
655
656 \begin_layout Plain Layout
657
658 \family typewriter
659 force
660 \end_layout
661
662 \end_inset
663 </cell>
664 </row>
665 <row endhead="true">
666 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
667 \begin_inset Text
668
669 \begin_layout Plain Layout
670
671 \family typewriter
672 pressure
673 \end_layout
674
675 \end_inset
676 </cell>
677 </row>
678 <row endhead="true">
679 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
680 \begin_inset Text
681
682 \begin_layout Plain Layout
683
684 \family typewriter
685 energy
686 \end_layout
687
688 \end_inset
689 </cell>
690 </row>
691 <row endhead="true">
692 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
693 \begin_inset Text
694
695 \begin_layout Plain Layout
696
697 \family typewriter
698 power
699 \end_layout
700
701 \end_inset
702 </cell>
703 </row>
704 <row endhead="true">
705 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
706 \begin_inset Text
707
708 \begin_layout Plain Layout
709
710 \family typewriter
711 absolute viscosity
712 \end_layout
713
714 \end_inset
715 </cell>
716 </row>
717 <row endhead="true">
718 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
719 \begin_inset Text
720
721 \begin_layout Plain Layout
722
723 \family typewriter
724 electric charge
725 \end_layout
726
727 \end_inset
728 </cell>
729 </row>
730 <row>
731 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
732 \begin_inset Text
733
734 \begin_layout Plain Layout
735
736 \family typewriter
737 miscellaneous electromagnetic
738 \end_layout
739
740 \end_inset
741 </cell>
742 </row>
743 <row>
744 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
745 \begin_inset Text
746
747 \begin_layout Plain Layout
748
749 \family typewriter
750 swiped from C math.h
751 \end_layout
752
753 \end_inset
754 </cell>
755 </row>
756 <row>
757 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
758 \begin_inset Text
759
760 \begin_layout Plain Layout
761
762 \family typewriter
763 constant based conversions
764 \end_layout
765
766 \end_inset
767 </cell>
768 </row>
769 <row>
770 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
771 \begin_inset Text
772
773 \begin_layout Plain Layout
774
775 \family typewriter
776 subtly dimensionless measures
777 \end_layout
778
779 \end_inset
780 </cell>
781 </row>
782 <row>
783 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
784 \begin_inset Text
785
786 \begin_layout Plain Layout
787
788 \family typewriter
789 light quantities
790 \end_layout
791
792 \end_inset
793 </cell>
794 </row>
795 <row>
796 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
797 \begin_inset Text
798
799 \begin_layout Plain Layout
800
801 \family typewriter
802 miscellaneous rates
803 \end_layout
804
805 \end_inset
806 </cell>
807 </row>
808 <row>
809 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
810 \begin_inset Text
811
812 \begin_layout Plain Layout
813
814 \family typewriter
815 time variant conversions
816 \end_layout
817
818 \end_inset
819 </cell>
820 </row>
821 </lyxtabular>
822
823 \end_inset
824
825
826 \end_layout
827
828 \end_inset
829
830
831 \end_layout
832
833 \begin_layout Section
834 Send them in
835 \end_layout
836
837 \begin_layout Standard
838 We are always on the lookout for useful unit conversions to add to
839 \family typewriter
840 measures.a4l
841 \family default
842 .
843 If you create a
844 \family typewriter
845 myunits.a4l
846 \family default
847 containing unit conversion definitions of general use (i.e.
848 not currency exchange rates and other time-varying conversions), please
849 mail us a copy and include your name in a comment.
850 Thank you very much.
851 \end_layout
852
853 \end_body
854 \end_document

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22