Is Schrödinger's Cat Object-Oriented? - Literate Programming

3y ago
34 Views
2 Downloads
662.00 KB
34 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Alexia Money
Transcription

Is Schrödinger's Cat Object-Oriented?Is Schrödinger's CatObject-Oriented?By Adolfo M. NemirovskyWhy Natural Scientists Should CareAbout Object-Oriented TechnologyObject-Oriented technology is gaining rapid acceptance among software developers,and is becoming the preferred choice for modern computer programming projects.Should a natural scientist care? We discuss some of the main concepts inobject-oriented programming and the potential of this interesting technology. The objectmodel views the world as made of many objects interacting (exchanging messages)with each other to produce a collective behavior. This picture resembles a quantumsystem of interacting particles. Suggestive analogies between the object model andquantum physics are identified and exploited in this work to provide an introduction toobject-oriented programmingThis paper is directed to natural scientists and graduate/advanced undergraduatestudents in physical sciences. Some basic concepts of quantum physics at the level ofintroductory courses in modern physics or physical chemistry is assumed. Backgroundin quantum mechanics is helpful but not required to understand most of this work. Noprior knowledge of C/C and object oriented programming is assumed. Most of theC code illustrating some of the physics examples presented in the paper is given inthe Appendices.Table of ContentsI. Why Object-Oriented?II. Basic Concepts in the Object ModelIII. The Object Model and Quantum PhysicsIV. Classes, Hierarchies and Quantum Field TheoriesV. Dynamics: Objects, Messages and Feynman DiagramsVI. Object-Oriented Design and Effective Hamiltonians. FrameworksVII. Multimedia, Parallel Universes and Path Integrals.1 of 34

Is Schrödinger's Cat Object-Oriented?VIII. Present and FutureAcknowledgmentsAPPENDIX A: Writing C Code I: The Class TVector3DAPPENDIX B: Writing C Code II: TParticle, TNucleon and TProtonClassesReferencesCopyrightI. Why Object-Oriented?Object-Oriented (OO) technology is becoming one of the most important technologiesin software development. It has enormous potential for significantly increasingprogrammer productivity and code maintainability.[1-3] Why is OO gaining such awidespread acceptance among commercial software developers and largecorporations? Procedural code of industrial strength (thousands of lines of code) isoften unstable under small perturbations, e.g., trying to fix a single problem mightcreate five new ones[2,3] When the code size is larger than some threshold (about10 5 lines of code), procedural techniques appear to break down: design andimplementation complexity makes projects quite difficult and expensive, and eventuallymaintenance cost dominates development cost[2,3] Object-Oriented techniquespromise to allow more stable and larger applications (several millions and tens ofmillions of lines of code) to be built[1-3] How can it be done? Why should a naturalscientist care?Natural scientists model and simulate natural phenomena. Computers simulate "real"(e.g., balancing a checkbook, mimicking the behavior of a physical system,.) and"imaginary" (e.g., games) worlds. Rapid advances in hardware and software aremaking possible the treatment of interesting and complex systems (e.g., turbulentflows, critical dynamics, lattice quantum chromodynamics, weather prediction, cellularmetabolism, social phenomena,.). Simula, a language that pioneered object-orientedtechnology was specially conceived for simulations. Hence, it is not surprising thatobject-oriented programming may make simulation and visualization of complexphenomena easier than procedural techniques (e.g., Fortran). For fully exploringmodels of complex systems, displaying results and data in a powerful manner (e.g.,scientific visualization, multimedia, virtual reality,.), for enhancing collaboration fullyexploiting networking facilities, OO technology appears better suited than procedurallanguages.The principle "divide and conquer" has been known for a long time as an efficienttechnique to conquer large empires (e.g., large codes). But, how to divide? Bothprocedural and OO programming employ the principle.The fundamental differencebetween these two models is the choice of building blocks. In procedural programming,procedures are the fundamental units (usually called subroutines or subprograms). Inthe object model, basic units are "cells" or "atoms" called objects which contain bothdata (i.e., state variables associated with the "atom" state at a given time) and methods(i.e., dynamical rules, rules that explain how "atoms" interact in the outside world). InOO terminology, objects encapsulate data and behavior. These objects are individualweakly interacting blocks. Objects interact (exchange messages) to produce collectivebehavior.OO views the word as composed of objects with well-defined properties. Object2 of 34

Is Schrödinger's Cat Object-Oriented?dynamics is pictured as interaction among objects. Interactions are mediated bymessages that objects exchange with each other. In fact, for a physicist this descriptionmay sound familiar as it resembles our modern view of the atomic and subatomicworld. This suggests that we could expect interesting analogies between QuantumPhysics (QP) and the object model (OM). These analogies are identified and exploitedin this work to present an introduction to the OO philosophy. Our examples use C asit currently is the most widely used OO language.[4].The main goal of this work is to provide an introduction to OO concepts for an audienceof natural scientists and graduate/advanced undergraduate students in the PhysicalSciences. We introduce some of the main OO ideas in this work at three differentlevels. At the highest level, we discuss general OO concepts, independent of thelanguage. At an intermediate level, and to produce more concrete examples, weexpress some of the QP concepts[5] in the C language. [C code is written in thisstyle, and adopts the Taligent notational style[6]]. Usually, in this process we select aparticular C design, the simplest to illustrate some OO features. Selected designsrarely are the "best" and usually oversimplify the physics. Thus, the code provided inthis work is mainly for didactic purposes and not intended for a real project.Section II presents some basic concepts in the object model (OM): abstraction,encapsulation, modularity and hierarchy. They are illustrated with examples from theatomic/subatomic world. Connections between the OM and some concepts in QuantumPhysics are presented in Section III. Table 1, at the end of that section, summarizessome of these analogies. Section IV discusses additional analogies between structuresin quantum physics and constructs in the object model, and then summarizes them inTable 2. Dynamics in the OM and in QP are discussed and contrasted in Section V.Section VI introduces the problem of object-oriented design of a complex system.Analogies between hypermedia and the path integral formulation of QP are presentedin Section VII. Finally, the last section collects some final thoughts and summarizessome of the experiences of earlier scientific users of the object-oriented technology.II. Basic Concepts in the Object ModelThe object model provides theoretical foundations upon which object-oriented design isbuilt. The OM is based[1] on the principles of abstraction, encapsulation, modularityand hierarchy, introduced in this section and expanded in the rest of the paper.Abstraction is well known to any natural scientist or anybody interested in modeling. Itconsists of extracting the relevant common features of the system to be modeled,providing adequate generalization, and removing irrelevant details. For example, allprotons in the universe share many properties: value of their masses, electric charges,spins,. (data) and the way they interact with themselves and other particles (methods).Protons are still protons, regardless of their location (inside our mouth or in a distantgalaxy) or their internal state (i.e., value of their momentum, orientation of their spin,.).Abstraction determines the characteristics of an object that distinguish it from otherkinds of objects (e.g. protons are different from neutrons or electrons, but two protonsin different atoms are still protons). This is the "outside view" of the object. That is howclients, particles that interact with the proton, see it. It is important to have the right setof abstractions for a given problem domain. For example, to different levels ofabstraction, protons and neutrons can be either viewed as different objects, or the3 of 34

Is Schrödinger's Cat Object-Oriented?same object (nucleon) in a different state. We will return to this later. There is a widespectrum of abstraction possibilities: objects could closely resemble "real" objects (carobject, pendulum object,.) but there could be quite "abstract" objects with apparently"no reason to exist" (shape object, transaction object, photon, Cooper pair,.).Encapsulation is also called information hiding. Clients (particles that interact withprotons) do not see a proton's internal structure ("inside view" of the object). That is,protons hide information about their internal structure. In general, the interface of aclass captures only the outside view. For example, electrons of hydrogen atoms do notknow the proton internal structure. They only see a proton's interface: its mass, electriccharge, linear momentum and spin. Encapsulation, then, is the process of hiding all theinternal details of an object.Modularity means that a system can be decomposed into a set of weakly coupledmodules. Hydrogen gas is composed of many loosely interacting objects (hydrogenmolecules). Each molecule is made of two weakly interacting objects (hydrogenatoms). In turn, each hydrogen atom consists of two objects (proton and electron) thatcollaborate (are bound together) exchanging messages (photons, the messengers, arethe carriers of the electromagnetic interaction). In general, one of the most difficultproblems in the OO design of complex systems is to "discover' the right modules tomimic the system. This difficulty is analogous to finding the "right" ground state in amany-body problem (e.g., superconductivity) as discussed later.Hierarchy is the ranking or ordering of abstractions. Consider a deuterium atom. It hasjust a single electron, but the nucleus consists of a neutron and a proton. Electrons inthe deuterium atom interact (exchange messages photons) with charged protonsthrough the electromagnetic interaction. Neutrons are uncharged particles so, at thislevel of abstraction, electrons see neutrons and protons as different particles (objects).At a higher level of abstraction, now inside the deuterium nucleus, protons andneutrons "collaborate" by sending "attractive" messages to each other (exchangingpions). They view each other as different states of the same particle (in physicistslanguage, they are members of a SU(2) doublet). At still higher levels of abstraction,nucleons (protons or neutrons) are just possible states of more abstract entities (SU(N)multiplets, with N 3, 4,.) that encompass a large number of distinct particles at lowerlevels of abstractions. Fig. 1 displays this example of subatomic hierarchical layering.4 of 34

Is Schrödinger's Cat Object-Oriented?Figure 1. Subatomic hierarchical layering: in this picture we distinguish three levels ofabstraction. In atomic physics, layer 1, we describe the physics in terms of interactingelectron and nucleus objects. Inside the nucleus, layer 2, the appropriate objects areprotons and neutrons. Finally, at higher collision energy, layer 3, the proton is viewedas made of interacting quark objects.III. The Object ModelandQuantum PhysicsObjects, the basic units in OO design, have state, behavior and identity. Methods ormember functions are operations that act upon objects and may modify their states.These concepts are introduced in this section using analogies with QP. Since linearalgebra is the mathematical language of quantum mechanics, these analogies betweenOM and QP are also expressible in the linear algebra language.In QP[5]], the description of the state of a system (say, a particle) at a given time isdefined by specifying its state vector. This vector belongs to the state space E (whichcomprises all possible states of the system). The set of distinct states of a system caneither be finite or infinite (countable or continuous). [Of course, the computerrepresentation of the state space is always finite]. The description of the state of anobject in the OM follows from the above by just replacing "system" (or "particle") by"object". Examples:1) Consider an Ising spin or Boolean variable. This object can only take two values: up(on or 1) and down (off or -1). These two distinct states can be represented by thevectors5 of 34

Is Schrödinger's Cat Object-Oriented?We have used the so-called Dirac notation to denote a state vector. This example iseasily generalizable for objects with 3, 4,. states.Given the two states up and down, in QP a state vector could be any linear combinationof these two basis vector. The only constraint is that vectors are normalized (i.e., thenorm of the vector should be unity). Hence, a more general state vector s for thetwo-state system has the formThe interpretation is the following: the spin is in a state with probability cos 2 (theta) tobe up , and sin 2 (theta) to be down . Conservation of probability (i.e., cos 2 (theta) sin 2 (theta) 1) constrains the state vectors to be normalized.In our C design, an object of the type Ising spin is denoted anIsingSpin . This objectencapsulates data, i.e., the value of the spin 1 or -1, and methods such as Flip() ,discussed later. In the OO literature usually one assigns either state up or down tothe object, but not some linear combination of these two vectors. An object, in thecommon OM usage, resembles more a "classical" entity than "quantum" one. This isnot a limitation of the OM. In fact, the OM is equally suited to model quantummechanics by assigning a "probabilistic" interpretation to the states of an object.2) Consider a "classical" three dimensional real vector object. In this case there is acontinuum of states. Once a coordinate system is chosen, say, Cartesian, states arelabeled by the x, y and z coordinates of the vector. Our vector object can berepresented in the Dirac notation as x, y, z . In our C model, we just call it aVector3Dand model it as a 3-dimensional array. The coordinates x, y and z are the data that theobject encapsulates. There are methods such as RotateZ(theta) discussed later which acton the object's data and produce a rotated vector.3) Consider a spinless particle. It is described by its state vector k with k (kx, ky, kz)the linear momentum coordinates. The quantities ki, i x, y and z are real numbers. Analternative description of the same particle might be in terms of the position state vector x with x a three dimensional vector, i. e., x (x, y, z). The particle state vector isrelated to the probability of finding the particle in a particular spacial region (or with aparticular value of linear momentum). In our design, we denote the particle aParticle. Itencapsulates data (say the value k of the momentum) and methods such asMomentumTransfer() given below.Identity [1,2] is the property that distinguishes an object from all other objects. Forexample, this proton, now in my mouth, is not the same as (but it is identical to) thatproton now at a distant galaxy. In QP each object defines its own vector spacespanned by a complete set of linearly independent vectors associated with all itspossible states. In the OM common usage, identity of objects is always preserved evenwhen states are completely changed. A proton object is still the same object even if itsmomentum and spin changes because of interaction with other objects. In other words,identity means that there is a unique state vector space associated with each object.Although in classical physics identity is always preserved, in quantum physics andNature, sometimes an object could either have a "non-sharp" identity, or evencompletely lose its identity. This could, but usually is not, be modelled in the OM,[3] andit is further discussed in the following sections.6 of 34

Is Schrödinger's Cat Object-Oriented?Behavior[1,2] is how an object acts or reacts in the presence of other objects, i.e., howit interacts with the external world. Behavior could also be defined as response toactions (i.e., response function). Operations that affect the object and possibly modifyits state are called methods or, in the C terminology, member functions. In QP,methods correspond to operators, that is, the state of the system is modified byapplying an operator (i.e., a matrix) O on the state vector s1 , producing a new vector s2 as a result, i.e., s2 O s1 ;The above operation might be written in the OM language (employing C notation) asmyObject.SetState(s2);where myObject is an object whose initial state is s1, and that makes a transition to s2after applying the method SetState() . This is an oversimplified representation as theSetState() method is independent of the initial state s1. A better design might bemyObject.ChangeState(r);where r s2 -s1 is the "distance" between the states s1 and s2.In QP, operators are linear (i.e., represented by matrices) acting on linear vectorspaces. On the other hand, in real life OO design, operators often are not linear. OOdesigns commonly employ operations that either change the state of objects (forexample, set-methods) or access their state (get-methods). Get-methods measuresome object's observables (or in the OO language, read the data encapsulated by theobject). Besides these, there are two very important methods called constructor anddestructor, which create and annihilate objects. As it could be guessed, they are closelyrelated to the creation and annihilation operators of second quantized quantummechanics, and they are discussed in the following section. Now we provide someexamples,1) For anIsingSpin object, we might have the following methods (operators)The method Flip() changes the state of the system, i.e., switches the state of the spinobject (i.e., up - down). In our C design we writeanIsingSpin.Flip();where anIsingSpin is an object of the type (class) TIsingSpin, initially in some state, say up .Application of the method Flip() , flips the spin so now anIsingSpin is in the state down . Analternative, matrix representation of this operation (assuming the initial state ofanIsingSpin was up) isThe methods SetUp() and SetDown() (set-methods) set the state of the spin to up anddown, irrespective of the previous state. Finally, the eigenvalues of GetSpin() provide theactual values of the spin (either up or down). In other words, up and down areeigenvectors of the GetSpin() operator with eigenvalues 1 and -1, respectively. In general,in the object model (and more general modeling) it might not be possible to define Getoperators (as in QP) such that their eigenvalues provide the only possible results ofmeasurements.7 of 34

Is Schrödinger's Cat Object-Oriented?2) For the TVector3D object one can define, among others, the following methodwhich rotates any TVector3D object, given in Cartesian coordinates, counterclockwise anangle theta around the z axis. In C notation, this operation can be written asaVector3D.RotateZ(theta);where the object aVector3D is of type TVector3D (that is, is a real three dimensional vector).After applying the method RotateZ(theta) to aVector3D, it changes state, rotating an amount(theta) around the z axis.3) The linear momentum operator P [denoted GetMomentum() in our design] accesses thestate of the proton (say, aProton) and reads its data,P p p p ,in C this reads,aProton.GetMomentum();Usually one also defines a momentum transfer opera

About Object-Oriented Technology Object-Oriented technology is gaining rapid acceptance among software developers, and is becoming the preferred choice for modern computer programming projects. Should a natural scientist care? We discuss some of the main concepts in object-oriented programming and the potential of this interesting technology .

Related Documents:

2007 cat d6t xl 2012 cat d6t lgp (3) 2006 cat d6r xl series iii 2004 cat d6r lgp 2012 cat d6n lgp (2) 2012 cat d6k-lgp (4) cat d6h lgp cat d6h 2012 cat d5k2-xl (3) 2008 cat d4g 2012 cat d3k lgp (3) 2002 john deere 750c 2006 john deere 700lgp 2013 komatsu d39 px motor graders cat 16g 2014 cat

2011 Cat 950H (1 of 3) 2008 Cat 740 2007 Cat D6R 20 April Rockingham Circuit, United Kingdom UNRESERVED PUBLIC AUCTION. . Crawler Loader 2006 Cat 953C Crawler Tractors 2007 Cat D6N LGP 2007 Cat D6R 2007 Cat D6R LGP Excavators 2013 Cat 308E 2012 Cat 308E (2) 2007 Cat D6R

Cat C2.4 (DI Turbo) Cat C4.4 Cat C7.1 ACERT Cat C4.4 ACERT Cat C7.1 ACERT Cat C7.1 Cat C7.1 Cat C9.3B Cat C7.1 ACERT Cat C9.3 Cat C13 Engine 47 91 157 143 157 260 212 311 259 346 405 Net Horse Power (hp) 0.25 0.65 1.2 1 1.3 - 1.4 1.8 1.6 2.12 1.88 2.69 2.41 - 3.21 Bucket Capacity (m3) Large boom base for strength and .

the finite square w ell, first for bound states and second for the above-w ell transm ission characteristic. S ec. III gives our conclusions. II. M O D E L an d R E S U L T S A . G en eral The discretized Schr dinger equation and its equivalent single-band tight-binding m odel are treated ex

cat 320e lrr 153 48,940 21’ 9” cat 321d l cr 148 53,704 . 22’ 10” cat 323f l 161 50,920 21’ 9” cat 324e l 190 55,664 22’ 0” cat 326f l 203 58,847 22’ 4” cat 330f l 239 68,209 23’ 9” cat 335f l cr 200 83,703 . 23’ 8” cat 336f l 300 82,917 24’ 7” .

Flowchart of Animated Story *Initial state* Background: Railroad Cat: What should we do? Cat: Left side Dog: Right side *Introductions* *Color* Cat says: Lets do Tricks! Cat: I can change colors! Cat changes to 5 colors Cat changes back *Whirl* Cat says I can whirl Cat whirls 5 times Cat changes back Flowchart of Animated Story *Initial state*

goria crociera tubo interno tubo esterno cate-goria crociera tubo interno tubo esterno 540 giri min 1000 giri min 540 giri min 1000 giri min kw kw kw kw cat. 1 12 18 cat. 5 35 54 cat. 2 15 23 cat. 6 47 74 cat. 3 26 40 cat. 7 55 83 cat. 4 26 40 cat. 8 70 110 potenze pag. 067 frizione a dischi di attrito .

CLAMP METER SELECTION GUIDE 61-775 61-765 61-757 61-747 FEATURES CAT Rating (Safety) CAT IV 600V CAT III 1000V CAT IV 600V CAT III 1000V CAT IV 600V CAT III 1000V CAT III 600V Listing cULus, CE, RCM cULus, CE, RCM cULus, C