The SD Model in Depth
Functions
Functions are the basis for modeled flow and instantaneous converter definitions. Functions also define the basis for any customized model component or factory. Functions encompass mathematical, statistical, financial and date-time operations. Where a symbol’s graphic cue is a stylized italic “ƒ” as is the case with customized model components and factories, and only one operation is applied, the graphic cue will show the operation.
The following functions are implemented in the SD Calculator. They are essential to build sophisticated system dynamics models.
Mathematical, JAVA Strict Math and fdLibM (IEEE 754) Functions
The following mathematical functions are implemented by a converter.
Constants
•Zero, One 0, 1, -1
•Pi π
•Euler’s constant e
•Largest Number +/- ∞ or +/- (2-2-23) x 2127 or approximately +/- 3.4028 x 1038
•Smallest Number +/- 1/∞ or +/- 2-126 or approximately +/- 1.1755 x 10-38
•nan Not a number – a defined binary byte
•null Null - nothing
Note that extended and double precision calculations will have different “smallest” and “largest” numbers
Arithmetic operations
•Sum x + y
•Difference x – y
•Product x * y
•Quotient x / y
Logical comparison operations
•Equal =
•Not Equal ≠
•Less than <
•Greater than >
•Less than or equal ≤
•Greater than or equal ≥
Boolean comparison operations
•Is ≡
•Not ¬
•And ∧
•Or ∨
•Exclusive Or (XOR) ⊻
Negation is also allowed such as Not And or Nand (¬∧ or ⊼)
Conversions to integer in floating-point type
•Round round(x)
•Round downward floor(x)
•Round upward ceil(x)
•Round toward zero trunc(x)
Comparison operations
•Minimum min(x,y)
•Maximum max(x,y)
•Positive difference dim(x,y)
Sign manipulation functions
•|x| abs(x)
Exponential functions
•ex exp(x)
•Ex 10exp(x)
•xy pow(x,y)
Logarithmic functions
•ln x log(x)
•log10 x log10(x)
•logx y logx(y)
Trigonometric functions
•cos x cos(x)
•sin x sin(x)
•tan x tan(x)
•arccos x acos(x)
•arcsin x asin(x)
•arctan x atan(x)
Hyperbolic functions
•cosh x cosh(x)
•sinh x sinh(x)
•tanh x tanh(x)
•arccosh x acosh(x)
•arcsinh x asinh(x)
•arctanh x atanh(x)
Error and gamma functions
•error x erf(x)
•Γ(x) gamma(x)
Miscellaneous functions
•Degrees to radians toRadians
•Radians to degrees toDegrees
•Square sq(x)
•Cube cb(x)
•Square root sqrt(x)
•Cube root cbrt(x)
•Hypotenuse hypot(x,y)
•Remainder remainder(x,y)
•Sign of a number signum(x)
•Random number random(x)
Financial Functions
Financial functions are implemented either in a converter or a factory model component. The decision of which implementation is chosen rests on the time-wise nature of the function and the function library utilized by the developer.
Time value of money operations:
Source data for time value of money calculations (solve for any one given the others):
-PV present value
-FV future value
-n number of periods
-I interest rate
-PMT payment (and payment timing at the beginning or end of the period)
Two period specifications are processed:
-N now
-m for a period number from 0 to n
•P principle part of payment now N, at a period m
•I interest part of payment now N, at a period m
•ΣP cumulative principle paid now N, at a period m
•ΣI cumulative interest paid now N, at a period m
•ΣPMT cumulative payments paid now N, at a period m
•V value now N, at a period m
•m period for a value V
•mPV periods since present value for a value V or now N
•mFV periods to future value for a value V or now N
Depreciation operations:
Source data for asset depreciation calculations:
-Cost (basis)
-Salvage value at end of life
-Lifetime (months or years)
-Start of period (start of year, middle of year, a month of a year, or a date)
Four depreciation methods are processed:
-SL straight line
-DB declining balance
-DDB double declining balance
-SYD sum of years digits
Two period specifications are processed:
-N now
-m for a period number from 0 to n
Three results are calculated :
-D depreciation for a specified period
-ΣD accumulated depreciation at a specified period
-DV depreciated value at a specified period
•SL depreciation now N, for a period m
•DB depreciation now N, for a period m
•DDB depreciation now N, for a period m
•SYD depreciation now N, for a period m
•SL accumulated depreciation now N, at a period m
•DB accumulated depreciation now N, at a period m
•DDB accumulated depreciation now N, at a period m
•SYD accumulated depreciation now N, at a period m
•SL depreciated value now N, at a period m
•DB depreciated value now N, at a period m
•DDB depreciated value now N, at a period m
•SYD depreciated value now N, at a period m
Ratios calculations:
•Current ratio
•Quick ratio
•Cash ratio
•Cash coverage ratio
•Times interest earned
•Asset turnover
•Inventory turnover
•Accounts payable turnover
•Accounts receivable turnover
•Average collection period
•Net profit margin (NP)
•Gross profit margin (GP)
•Return on assets (ROA)
•Return on equity (ROE)
•Return on investment (ROI)
•Dividend payout ratio (DPO)
•Earnings per share (EPS)
•Price earnings ratio (P/E)
•Equity multiplier ratio (A/E)
•Debt equity ratio (D/E)
•Debt assets ratio (D/A)
Other financial operations:
•Annual Percentage Rate (APR)
•Net Present Value (NPV)
•Internal Rate of Return (IRR, modified IRR)
•Bond Yield to Maturity (YTM)
•Bond Price (BPR)
•Capital Asset Pricing Model (CAPM)
•Constant Growth Model (CGM)
•Option Pricing Model (OPM)
Statistical Functions
Statistical functions are typically implemented by a factory model component as they operate on one or more data sets that might ordinarily result from a simulation. In conventional calculator mode, the statistical factories accept inputs in the form of an array or a matrix of data.
Descriptive Statistics:
•Count
•Minimum
•Maximum
•Range
•Mean (arithmetic, geometric, harmonic)
•Median
•Mode
•Quantile (quartile, quintile, decile, percentile)
•Deviation (standard, mean absolute, median absolute, maximum absolute)
•Coefficient of variation
•Variance
•Semivariance
•Skewness
•Kurtosis
Inferential Statistics:
•ANOVA analysis of variance
•ANCOVA analysis of covariance
•Normal probability density
•Normal cumulative distribution
•Binomial individual terms distribution
•Binomial cumulative terms distribution
•Poisson individual terms distribution
•Poisson cumulative terms distribution
•Beta distribution
•Gamma distribution
•Weibull distribution
•Z (normal) test
•T distribution
•T test
•Chi-squared distribution
•Chi-squared test
•F distribution
•F test
Correlation Analysis:
•Pearson product-moment
•Spearman’s rho
•Kendall’s tau
Regression Analysis (this section requires additional work)
Physical and Chemical Functions (this section requires additional work)
Physical and chemical functions are implemented either in a converter of a factory model component. The decision of which implementation is chosen rests on the time-wise nature of the function and the function library utilized by the developer.
Reactions of ions, atoms and molecules:
•acidity
•basicity
•oxidation
•reduction
•metal exchange
•pericyclic
Reactions of structural change:
•addition
•elimination
•substitution
•rearrangement
Reactions of functional groups:
•alkane
•alkene
•alkyne
•halide
•alchohol
•ether
•amine
•phosphene
•benzene
•nitro
•thiol
•sulfide
•nitrile
•aldehyde
•kytone
•carboxylic
•carboxylic derivative
•ester
•halide
•amide
•anhydride
Date and Time Functions
Types supported:
•Structure of Date and Time record
year;
month;
date;
hour;
minute;
second;
monthOfYear;
dayOfWeek;
timeZone
•Date and Time numeric string
YYYY-MM-DD HH:MM:SS±HHMM
•Structure of Long Date and Time record
era;
year;
month;
date;
hour;
minute;
second;
millisecond;
am/pm;
timeZone
Basic date and time functions:
•Get date and time
•Get date
•Get time
•Get time zone
•Get dayNumberOfWeek
•Get dayNumberOfYear
•Get weekNumberOfMonth
•Get weekNumberOfYear
•Set date and time
•Set date
•Set time
•Set time zone
Convert date and time strings into numeric representations:
•String to date and time
•String to date
•String to time
Convert numeric representations into date and time strings:
•Date and time to string
•Date to string
•Time to string
Time interval operations:
•Date with time interval since now
•Date interval since now; Time interval since now
•Date with time interval since date
•Date interval since date; Time interval since date
•Add date interval
•Add time interval
•Subtract date interval
•Subtract time interval
Date and time comparison operations:
•Compare date and time
•Compare date
•Compare time
•IsEqualTo date
•Earlier date
•Later date
Other Functions
Personalization and Localization:
•Get user
•Get / Set language
•Get/ Set location
•Get / Set default symbol size of small, medium or large
•Get / Set default symbol spacing of tight, moderate or loose
Number conversion:
•Get / Set number system
•Convert to Base2
•Convert to Base8
•Convert to Base10
•Convert to Base16
•Convert from / to
Notation conversion:
•Convert to fraction (to k/n or k/2n for n ≤ user specification)
•Convert to decimal
Currency conversion (ISO 4217, 10646):
•Get / Set currency system
•Convert to USD ($) United States Dollar
•Convert to AUD (A$) Australian Dollar
•Convert to CAD (C$) Canadian Dollar
•Convert to MXN (M$) Mexican Peso
•Convert to EUR (€) Euro
•Convert to GBP (£) Pound
•Convert to RUB (Руб) Ruble
•Convert to JPY (¥) Yen
•Convert to CNY (元) Yuan Renminbi
•Convert to KRW (₩) Won
•Convert to INR (₨) Rupees
•Convert to XAU (oz) gold (ounces)
•Convert from / to
Unit of measure conversion:
•Get / Set unit system
•Convert to Metric (meter, kilogram, liter, degC)
•Convert to Metric-Small (centimeter, gram, millimeter, degC)
•Convert to English (foot, pound, gallon, degF)
•Convert to English-Small (inch, ounce, ounce, degF)
•Convert from / to
Solver (inverse function solution):
• x = ƒ-1 (y) sol(y,ƒ(x))
Script commands and conditionals:
•If, Then, Else
•Do (a script)
•Display / Clear Display (a result, text string, picture)
•Print (a model, report, graph or table)
•Load, Unload (a model)
•Select (a page, palette, simple table/graph)
•Start, Stop, Pause, Resume (a simulation, movie)
•Wake, Sleep, Shut Down (the calculator)
•At, After (a time, an interval)
•On (reference to system events)
•Loop / End Loop
Abstraction Layers, Fragments and Scripts
Functions
Mathematical, JAVA Strict Math and fdLibM (IEEE 754) Functions
Financial Functions
Statistical Functions
Physical and Chemical Functions (this section requires additional work)
Date and Time Functions
Other Functions
Appendix: The Modeling Process