Spark 2.0 Reference Manual
Total Page:16
File Type:pdf, Size:1020Kb
SPARK 2.0 REFERENCE MANUAL Simulation Problem Analysis and Research Kernel Copyright 1997-2003 Lawrence Berkeley National Laboratory Ayres Sowell Associates, Inc. Pending approval of the U.S. Department of Energy. All rights reserved. This work was supported by the Assistant Secretary for Energy Efficiency and Renewable Energy, Office of Building Technologies Program of the U.S. Dept. of Energy. Contract No. DE-AC03-76SF00098. SPARK 2.0 Reference Manual TABLE OF CONTENTS TABLE OF CONTENTS ................................................................................................................................................II FOREWORD ................................................................................................................................................................VII LICENSES AND COPYRIGHTS............................................................................................................................. VIII TEXT CONVENTIONS ............................................................................................................................................... IX 1 INTRODUCTION ...................................................................................................................................................1 1.1 WHAT IS SPARK? ..............................................................................................................................................1 1.2 KINDS OF PROBLEMS THAT SPARK CAN SOLVE ................................................................................................1 1.3 DESCRIBING PROBLEMS FOR SPARK SOLUTION ................................................................................................1 1.4 PORTABILITY AND USER INTERFACES ................................................................................................................3 1.5 THE HISTORY OF SPARK ...................................................................................................................................3 1.6 VERSIONS OF SPARK.........................................................................................................................................4 2 BASIC METHODOLOGY .....................................................................................................................................5 2.1 OVERVIEW AND TERMINOLOGY.........................................................................................................................5 2.2 A PROBLEM WITH A SINGLE OBJECT..................................................................................................................6 2.2.1 Running the SPARK Problem .......................................................................................................................7 2.2.2 Arbitrary Input/Output Designation.............................................................................................................8 2.3 PROBLEMS WITH SEVERAL OBJECTS ..................................................................................................................9 2.4 PROBLEMS REQUIRING ITERATIVE SOLUTION ..................................................................................................11 2.5 ITERATIVE SOLUTION AND BREAK VARIABLES................................................................................................13 2.6 WELL-POSED PROBLEMS .................................................................................................................................14 3 CREATING SINGLE-VALUED ATOMIC CLASSES ......................................................................................16 3.1 CLASS DEFINITION...........................................................................................................................................16 3.1.1 The PORT Statement..................................................................................................................................17 3.1.2 The EQUATIONS Statement......................................................................................................................17 3.1.3 The FUNCTIONS Statement......................................................................................................................17 3.2 INVERSE FUNCTIONS DEFINITION.....................................................................................................................18 3.2.1 Basic Structure of a Single-Valued EVALUATE Callback .........................................................................18 3.2.2 Defining the C++ Callback Function.........................................................................................................19 3.2.3 Defining the Argument Variables ...............................................................................................................19 3.2.4 Calculating the Result Value ......................................................................................................................19 3.2.5 Returning the Result Value .........................................................................................................................20 3.3 SYMBOLIC PROCESSING ...................................................................................................................................20 3.3.1 Simple Symbolic Processing.......................................................................................................................21 3.3.2 Generating an Inverse ................................................................................................................................21 3.3.3 Caveats .......................................................................................................................................................21 4 CREATING MULTI-VALUED ATOMIC CLASSES.......................................................................................23 4.1 MOTIVATION....................................................................................................................................................23 4.2 LIMITATIONS....................................................................................................................................................24 4.3 CLASS DEFINITION...........................................................................................................................................24 4.3.1 The PORT Statement..................................................................................................................................25 4.3.2 The EQUATIONS Statement......................................................................................................................26 4.3.3 The FUNCTIONS Statement......................................................................................................................26 4.4 INVERSE FUNCTION DEFINITION ......................................................................................................................26 4.4.1 Defining the C++ Callback Function.........................................................................................................26 ii SPARK 2.0 Reference Manual 4.4.2 Defining the Argument Variables ...............................................................................................................26 4.4.3 Defining the Target Variables ....................................................................................................................26 4.4.4 Calculating the Result Values.....................................................................................................................27 4.4.5 Returning the Result Values........................................................................................................................28 4.4.6 Basic Structure of a Multi-Valued EVALUATE Callback...........................................................................29 5 MODELS OF PHYSICAL SYSTEMS ................................................................................................................31 5.1 UNITS, VALID RANGE, AND INITIAL VALUES...................................................................................................31 5.2 MACRO CLASSES .............................................................................................................................................32 6 DIFFERENTIAL EQUATIONS ..........................................................................................................................36 6.1 NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS ....................................................................................36 6.2 SOLVING A SIMPLE DIFFERENTIAL EQUATION .................................................................................................37 6.3 INTEGRATOR CLASSES IN THE SPARK LIBRARY ..............................................................................................39 6.4 CREATING SPARK INTEGRATOR OBJECT CLASSES ..........................................................................................41 6.4.1 Simplified Implementation of the Euler Method .........................................................................................41 6.4.2 The Initialization Issue ...............................................................................................................................42 6.4.3 The Restart Issue ........................................................................................................................................43