SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
Modeling Physical Systems
               with Modern Object Oriented Perl
                      YAPC::NA 2012

                              Joel Berger

                      University of Illinois at Chicago


                            June 15, 2012




Joel Berger (UIC)            OO Physical Modeling         June 15, 2012   1 / 15
The Problems


Physical Simulations


Differential Equations
A set of rules that define how variables change with some parameter
                                                      dx
                          x(t2 ) = x(t1 ) + dt ∗
                                                      dt




Example: Exponential Growth
                         dM
                             = rM        =⇒          M (t) = P exp(rt)
                          dt



     Joel Berger (UIC)                  OO Physical Modeling             June 15, 2012   2 / 15
The Problems


Physical Simulations


Differential Equations
A set of rules that define how variables change with some parameter
                                                      dx
                          x(t2 ) = x(t1 ) + dt ∗         (x, f (t1, t2))
                                                      dt




Example: Exponential Growth
                         dM
                             = rM        =⇒          M (t) = P exp(rt)
                          dt



     Joel Berger (UIC)                  OO Physical Modeling               June 15, 2012   2 / 15
The Problems


Physical Simulations


Differential Equations
A set of rules that define how variables change with some parameter
                                                      dx
                          x(t2 ) = x(t1 ) + dt ∗         (x, f (t1, t2))
                                                      dt




Example: Exponential Growth
                         dM
                             = rM        =⇒          M (t) = P exp(rt)
                          dt



     Joel Berger (UIC)                  OO Physical Modeling               June 15, 2012   2 / 15
The Problems


My Research: Ultrafast Electron Microscopy




    Joel Berger (UIC)       OO Physical Modeling   June 15, 2012   3 / 15
The Problems


My Research: Ultrafast Electron Microscopy




                        Photocathode       Magnetic Lenses    Detector




    Joel Berger (UIC)               OO Physical Modeling     June 15, 2012   3 / 15
The Problems


My Research: Ultrafast Electron Microscopy




        Laser
                        Photocathode       Magnetic Lenses    Detector




    Joel Berger (UIC)               OO Physical Modeling     June 15, 2012   3 / 15
The Problems


My Research: Ultrafast Electron Microscopy




                                                           Electron Beam




        Laser
                        Photocathode       Magnetic Lenses            Detector




    Joel Berger (UIC)               OO Physical Modeling             June 15, 2012   3 / 15
The Problems


My Research: Ultrafast Electron Microscopy




                                               RF Cavity
                                                           Electron Beam




        Laser
                        Photocathode       Magnetic Lenses            Detector




    Joel Berger (UIC)               OO Physical Modeling             June 15, 2012   3 / 15
The Problems


The Challenge: A Flexible Interface to a Complex Model

                   Magnetic Lens          Magnetic Lens
Electron Pulse
             v = vˆ
                  z
  w


         l                    RF Cavity
                               “z lens”
      Need: Compute dynamics of electron pulse (w(t), l(t))
      Note: Generation and optical elements add terms to DE
      Want: Representitive OO user-level interface



      Joel Berger (UIC)            OO Physical Modeling       June 15, 2012   4 / 15
The Problems


The Challenge: A Flexible Interface to a Complex Model

                   Magnetic Lens          Magnetic Lens
Electron Pulse
             v = vˆ
                  z
  w


         l                    RF Cavity
                               “z lens”
      Need: Compute dynamics of electron pulse (w(t), l(t))
      Note: Generation and optical elements add terms to DE
      Want: Representitive OO user-level interface



      Joel Berger (UIC)            OO Physical Modeling       June 15, 2012   4 / 15
The Problems


The Challenge: A Flexible Interface to a Complex Model

                   Magnetic Lens          Magnetic Lens
Electron Pulse
             v = vˆ
                  z
  w


         l                    RF Cavity
                               “z lens”
      Need: Compute dynamics of electron pulse (w(t), l(t))
      Note: Generation and optical elements add terms to DE
      Want: Representitive OO user-level interface



      Joel Berger (UIC)            OO Physical Modeling       June 15, 2012   4 / 15
The Problems


The Challenge: A Flexible Interface to a Complex Model

                   Magnetic Lens          Magnetic Lens
Electron Pulse
             v = vˆ
                  z
  w


         l                    RF Cavity
                               “z lens”
      Need: Compute dynamics of electron pulse (w(t), l(t))
      Note: Generation and optical elements add terms to DE
      Want: Representitive OO user-level interface



      Joel Berger (UIC)            OO Physical Modeling       June 15, 2012   4 / 15
The Problems


The “State of the Art”

Old codes are
    lacking full 6D dynamics
    optimized for performance vs usablilty
    hard to customize
    near impossible to comprehend

http://laacg.lanl.gov/laacg/services/download_sf.phtml
Getting Started with Poisson Superfish
. . . We do not recommend trying to build an input file “from scratch.”
Instead, find an example file that is similar to the problem you are trying
to solve. Make a copy of the file and then make any necessary
modifications to the geometry and options.


     Joel Berger (UIC)          OO Physical Modeling         June 15, 2012   5 / 15
The Problems


The “State of the Art”

Old codes are
    lacking full 6D dynamics
    optimized for performance vs usablilty
    hard to customize
    near impossible to comprehend

http://laacg.lanl.gov/laacg/services/download_sf.phtml
Getting Started with Poisson Superfish
. . . We do not recommend trying to build an input file “from scratch.”
Instead, find an example file that is similar to the problem you are trying
to solve. Make a copy of the file and then make any necessary
modifications to the geometry and options.


     Joel Berger (UIC)          OO Physical Modeling         June 15, 2012   5 / 15
The Problems


Other Attempts
                                           Modelica:
                                           Pros:
Mathematica:
                                                  Open-source, but behind
Pros:
                                                  close-source variants
    Can solve dynamics
                                                  Unique OO language for
    Pretty-printing of math for                   physical simulation
    readability
                                                  Classes have DEs as properties
Cons:
                                           Cons:
    Closed-source and expensive!
                                                  Lacks “has-a” relationship
    No OO and no key-value
                                                  Composing DEs not trivial
    datatypes
                                                  User-facing object instantiation
    Still rather slow ∼2mins/sim
                                                  not trivial
                                                  Some numerical problems (?)

        Joel Berger (UIC)       OO Physical Modeling                June 15, 2012   6 / 15
The Problems


Other Attempts
                                           Modelica:
                                           Pros:
Mathematica:
                                                  Open-source, but behind
Pros:
                                                  close-source variants
    Can solve dynamics
                                                  Unique OO language for
    Pretty-printing of math for                   physical simulation
    readability
                                                  Classes have DEs as properties
Cons:
                                           Cons:
    Closed-source and expensive!
                                                  Lacks “has-a” relationship
    No OO and no key-value
                                                  Composing DEs not trivial
    datatypes
                                                  User-facing object instantiation
    Still rather slow ∼2mins/sim
                                                  not trivial
                                                  Some numerical problems (?)

        Joel Berger (UIC)       OO Physical Modeling                June 15, 2012   6 / 15
The Problems


Other Attempts
                                           Modelica:
                                           Pros:
Mathematica:
                                                  Open-source, but behind
Pros:
                                                  close-source variants
    Can solve dynamics
                                                  Unique OO language for
    Pretty-printing of math for                   physical simulation
    readability
                                                  Classes have DEs as properties
Cons:
                                           Cons:
    Closed-source and expensive!
                                                  Lacks “has-a” relationship
    No OO and no key-value
                                                  Composing DEs not trivial
    datatypes
                                                  User-facing object instantiation
    Still rather slow ∼2mins/sim
                                                  not trivial
                                                  Some numerical problems (?)

        Joel Berger (UIC)       OO Physical Modeling                June 15, 2012   6 / 15
The Problems


Other Attempts
                                           Modelica:
                                           Pros:
Mathematica:
                                                  Open-source, but behind
Pros:
                                                  close-source variants
    Can solve dynamics
                                                  Unique OO language for
    Pretty-printing of math for                   physical simulation
    readability
                                                  Classes have DEs as properties
Cons:
                                           Cons:
    Closed-source and expensive!
                                                  Lacks “has-a” relationship
    No OO and no key-value
                                                  Composing DEs not trivial
    datatypes
                                                  User-facing object instantiation
    Still rather slow ∼2mins/sim
                                                  not trivial
                                                  Some numerical problems (?)

        Joel Berger (UIC)       OO Physical Modeling                June 15, 2012   6 / 15
The Problems


Other Attempts
                                           Modelica:
                                           Pros:
Mathematica:
                                                  Open-source, but behind
Pros:
                                                  close-source variants
    Can solve dynamics
                                                  Unique OO language for
    Pretty-printing of math for                   physical simulation
    readability
                                                  Classes have DEs as properties
Cons:
                                           Cons:
    Closed-source and expensive!
                                                  Lacks “has-a” relationship
    No OO and no key-value
                                                  Composing DEs not trivial
    datatypes
                                                  User-facing object instantiation
    Still rather slow ∼2mins/sim
                                                  not trivial
                                                  Some numerical problems (?)

        Joel Berger (UIC)       OO Physical Modeling                June 15, 2012   6 / 15
Perl Solution


. . . But First, Some Bookkeeping

If an object knows where it is, can it remember where it came from?
use MooseX::Declare;
use Method::Signatures::Modifiers;
use MooseX::RememberHistory;

class MyClass {                                     use objects as data storage
  has ’x’ => (
    traits => [’RememberHistory’],
                                                         current data during
    isa => ’Num’, is => ’rw’,                            simulation
    default => 0                                         all data afterwards
  );
}                                                   works for fixed width solvers
my $obj = MyClass->new;
                                                    adaptive solvers call functions
$obj->x( 1 );                                       repeatedly (i.e. PerlGSL::DiffEq)
$obj->x( 2 );

print join ’, ’, @{ $obj->x_history };
# 0, 1, 2


      Joel Berger (UIC)           OO Physical Modeling                June 15, 2012   7 / 15
Perl Solution


. . . But First, Some Bookkeeping

If an object knows where it is, can it remember where it came from?
use MooseX::Declare;
use Method::Signatures::Modifiers;
use MooseX::RememberHistory;

class MyClass {                                     use objects as data storage
  has ’x’ => (
    traits => [’RememberHistory’],
                                                         current data during
    isa => ’Num’, is => ’rw’,                            simulation
    default => 0                                         all data afterwards
  );
}                                                   works for fixed width solvers
my $obj = MyClass->new;
                                                    adaptive solvers call functions
$obj->x( 1 );                                       repeatedly (i.e. PerlGSL::DiffEq)
$obj->x( 2 );

print join ’, ’, @{ $obj->x_history };
# 0, 1, 2


      Joel Berger (UIC)           OO Physical Modeling                June 15, 2012   7 / 15
Perl Solution


. . . But First, Some Bookkeeping

If an object knows where it is, can it remember where it came from?
use MooseX::Declare;
use Method::Signatures::Modifiers;
use MooseX::RememberHistory;

class MyClass {                                     use objects as data storage
  has ’x’ => (
    traits => [’RememberHistory’],
                                                         current data during
    isa => ’Num’, is => ’rw’,                            simulation
    default => 0                                         all data afterwards
  );
}                                                   works for fixed width solvers
my $obj = MyClass->new;
                                                    adaptive solvers call functions
$obj->x( 1 );                                       repeatedly (i.e. PerlGSL::DiffEq)
$obj->x( 2 );

print join ’, ’, @{ $obj->x_history };
# 0, 1, 2


      Joel Berger (UIC)           OO Physical Modeling                June 15, 2012   7 / 15
Perl Solution


. . . But First, Some Bookkeeping

If an object knows where it is, can it remember where it came from?
use MooseX::Declare;
use Method::Signatures::Modifiers;
use MooseX::RememberHistory;

class MyClass {                                     use objects as data storage
  has ’x’ => (
    traits => [’RememberHistory’],
                                                         current data during
    isa => ’Num’, is => ’rw’,                            simulation
    default => 0                                         all data afterwards
  );
}                                                   works for fixed width solvers
my $obj = MyClass->new;
                                                    adaptive solvers call functions
$obj->x( 1 );                                       repeatedly (i.e. PerlGSL::DiffEq)
$obj->x( 2 );

print join ’, ’, @{ $obj->x_history };
# 0, 1, 2


      Joel Berger (UIC)           OO Physical Modeling                June 15, 2012   7 / 15
Perl Solution


. . . But First, Some Bookkeeping

If an object knows where it is, can it remember where it came from?
use MooseX::Declare;
use Method::Signatures::Modifiers;
use MooseX::RememberHistory;

class MyClass {                                     use objects as data storage
  has ’x’ => (
    traits => [’RememberHistory’],
                                                         current data during
    isa => ’Num’, is => ’rw’,                            simulation
    default => 0                                         all data afterwards
  );
}                                                   works for fixed width solvers
my $obj = MyClass->new;
                                                    adaptive solvers call functions
$obj->x( 1 );                                       repeatedly (i.e. PerlGSL::DiffEq)
$obj->x( 2 );

print join ’, ’, @{ $obj->x_history };
# 0, 1, 2


      Joel Berger (UIC)           OO Physical Modeling                June 15, 2012   7 / 15
Perl Solution


. . . But First, Some Bookkeeping

If an object knows where it is, can it remember where it came from?
use MooseX::Declare;
use Method::Signatures::Modifiers;
use MooseX::RememberHistory;

class MyClass {                                     use objects as data storage
  has ’x’ => (
    traits => [’RememberHistory’],
                                                         current data during
    isa => ’Num’, is => ’rw’,                            simulation
    default => 0                                         all data afterwards
  );
}                                                   works for fixed width solvers
my $obj = MyClass->new;
                                                    adaptive solvers call functions
$obj->x( 1 );                                       repeatedly (i.e. PerlGSL::DiffEq)
$obj->x( 2 );

print join ’, ’, @{ $obj->x_history };
# 0, 1, 2


      Joel Berger (UIC)           OO Physical Modeling                June 15, 2012   7 / 15
Perl Solution   A Simple OO-DE Example


Physical Classes


use MooseX::RememberHistory;
use MooseX::Declare;
use Method::Signatures::Modifiers;

class MyForce {
  has ’strength’ => ( isa => ’Num’, is => ’rw’, default => 0 );
  has ’affect’   => ( isa => ’CodeRef’, is => ’ro’, required => 1 );
}

class MyThing {
  has ’mass’ => ( isa => ’Num’, is => ’ro’, required => 1 );
  has ’x’    => ( traits => [ ’RememberHistory’ ], isa => ’Num’,
                  is => ’rw’, default => 0 );
  has ’vx’   => ( traits => [ ’RememberHistory’ ], isa => ’Num’,
                  is => ’rw’, default => 0 );
}




     Joel Berger (UIC)           OO Physical Modeling                  June 15, 2012   8 / 15
Perl Solution   A Simple OO-DE Example


The Solver: Attributes

class MySim {
  use List::Util ’sum’;

 has ’start’      => ( isa => ’Num’, is => ’ro’, default => 0 );
 has ’end’        => ( isa => ’Num’, is => ’ro’, default => 1 );
 has ’steps’      => ( isa => ’Num’, is => ’ro’, default => 100 );

 has ’step’       => ( isa => ’Num’, is => ’ro’, lazy => 1, builder => ’init_step’);
 has ’time’       => ( traits => [ ’RememberHistory’ ], isa => ’Num’, is => ’rw’,
                       lazy => 1, builder => ’init_time’ );

 has ’things’ => ( isa => ’ArrayRef[MyThing]’, is => ’rw’, default => sub{[]} );
 has ’forces’ => ( isa => ’ArrayRef[MyForce]’, is => ’rw’, default => sub{[]} );

 method init_step () {
   my $step = ($self->end - $self->start) / $self->steps;
   return $step;
 }

 method init_time () { return $self->start }


     Joel Berger (UIC)              OO Physical Modeling                  June 15, 2012   9 / 15
Perl Solution   A Simple OO-DE Example


The Solver: Methods

 method evolve ( MyThing $thing ) {
   my $dt = $self->step;
   my $vx = $thing->vx;

     my $force = sum map { $_->affect->($_, $thing) } @{ $self->forces };
     my $acc = $force / ($thing->mass);

     $thing->vx( $vx + $acc * $dt );
     $thing->x( $thing->x + $vx * $dt );
 }

  method run () {
    while ($self->time < $self->end) {
      $self->evolve( $_ ) for @{ $self->things };
      $self->time( $self->time + $self->step );
    }
  }
} # end of class MySim



      Joel Berger (UIC)           OO Physical Modeling                  June 15, 2012   10 / 15
Perl Solution   A Simple OO-DE Example


The Script

#!/usr/bin/env perl                            my $sim = MySim->new(
use strict; use warnings;                        end => 5,
use MySim;                                       things => [ $thing ],
use PDL;                                         forces => [ $acc, $dec ],
use PDL::Graphics::Prima::Simple;              );

my $thing = MyThing->new( mass => 2 );         $sim->run;

my $acc = MyForce->new(                        my $time = pdl $sim->time_history;
  strength => 2,                               my $x    = pdl $thing->x_history;
  affect => sub {shift->strength},
);                                             line_plot($time, $x);

my $dec = MyForce->new(
  strength => -30,
  affect => sub {
    my ($self, $thing) = @_;
    return 0 if ($thing->x < 0.1);
    return $self->strength;
  },
);

      Joel Berger (UIC)             OO Physical Modeling                June 15, 2012   11 / 15
Perl Solution   A Simple OO-DE Example


The Script

#!/usr/bin/env perl                            my $sim = MySim->new(
use strict; use warnings;                        end => 5,
use MySim;                                       things => [ $thing ],
use PDL;                                         forces => [ $acc, $dec ],
use PDL::Graphics::Prima::Simple;              );

my $thing = MyThing->new( mass => 2 );         $sim->run;

my $acc = MyForce->new(                        my $time = pdl $sim->time_history;
  strength => 2,                               my $x    = pdl $thing->x_history;
  affect => sub {shift->strength},
);                                             line_plot($time, $x);

my $dec = MyForce->new(
  strength => -30,
  affect => sub {
    my ($self, $thing) = @_;
    return 0 if ($thing->x < 0.1);
    return $self->strength;
  },
);

      Joel Berger (UIC)             OO Physical Modeling                June 15, 2012   11 / 15
Units Handling


Unit Handling (The Implied Covenant)


Mars Surveyor ’98 Orbiter
    Software used force in Newtons
    Users entered force in Foot-Pounds


The Covenant:
    Between programmer and user
    “Use the same units!”
    Unexpected and possibly undocumented action at a distance
    With Perl and Moose we can do better . . .



    Joel Berger (UIC)            OO Physical Modeling   June 15, 2012   12 / 15
Units Handling


Unit Handling (The Implied Covenant)


Mars Surveyor ’98 Orbiter (Sorry Larry!)
    Software used force in Newtons
    Users entered force in Foot-Pounds


The Covenant:
    Between programmer and user
    “Use the same units!”
    Unexpected and possibly undocumented action at a distance
    With Perl and Moose we can do better . . .



     Joel Berger (UIC)           OO Physical Modeling   June 15, 2012   12 / 15
Units Handling


Unit Handling (The Implied Covenant)


Mars Surveyor ’98 Orbiter (Sorry Larry!)
    Software used force in Newtons
    Users entered force in Foot-Pounds


The Covenant:
    Between programmer and user
    “Use the same units!”
    Unexpected and possibly undocumented action at a distance
    With Perl and Moose we can do better . . .



     Joel Berger (UIC)           OO Physical Modeling   June 15, 2012   12 / 15
Units Handling


Unit Handling (The Implied Covenant)


Mars Surveyor ’98 Orbiter (Sorry Larry!)
    Software used force in Newtons
    Users entered force in Foot-Pounds


The Covenant:
    Between programmer and user
    “Use the same units!”
    Unexpected and possibly undocumented action at a distance
    With Perl and Moose we can do better . . .



     Joel Berger (UIC)           OO Physical Modeling   June 15, 2012   12 / 15
Units Handling


Unit Handling (The Implied Covenant)


Mars Surveyor ’98 Orbiter (Sorry Larry!)
    Software used force in Newtons
    Users entered force in Foot-Pounds


The Covenant:
    Between programmer and user
    “Use the same units!”
    Unexpected and possibly undocumented action at a distance
    With Perl and Moose we can do better . . .



     Joel Berger (UIC)           OO Physical Modeling   June 15, 2012   12 / 15
Units Handling


Unit Handling (The Implied Covenant)


Mars Surveyor ’98 Orbiter (Sorry Larry!)
    Software used force in Newtons
    Users entered force in Foot-Pounds


The Covenant:
    Between programmer and user
    “Use the same units!”
    Unexpected and possibly undocumented action at a distance
    With Perl and Moose we can do better . . .



     Joel Berger (UIC)           OO Physical Modeling   June 15, 2012   12 / 15
Units Handling


MooseX::Types::NumUnit

        Str   to   Num   coercions
        convert unit if needed

use MooseX::Declare;
use Method::Signatures::Modifiers;

class   SphericalCow {
  use   MooseX::Types::NumUnit qw/num_of_unit/;
  has   ’radius’   => ( isa => num_of_unit(’m’),   is => ’rw’, default => 1 );
  has   ’velocity’ => ( isa => num_of_unit(’m/s’), is => ’rw’, default => 0 );
}

use strict; use warnings;

my $cow = SphericalCow->new(
  radius => ’1 ft’,
);

print $cow->radius . "n"; # 0.3048


        Joel Berger (UIC)                 OO Physical Modeling    June 15, 2012   13 / 15
Real World Example


Example of Physics::UEMColumn

Back to Electron Column Modeling
             Magnetic Lens       Magnetic Lens
Electron Pulse
              v = vˆ
                   z
  w


         l                      RF Cavity
                                 “z lens”
      As yet unreleased     Physics::UEMColumn
             https://github.com/jberger/Physics-UEMColumn
      Uses:   PerlGSL::DiffEq   on CPAN
             C-level solver of Perl-level DE closures


      Joel Berger (UIC)               OO Physical Modeling   June 15, 2012   14 / 15
Finally


Acknowledgements




   Graduate College Dean’s Fellowship (Major Student Funding)
   LAS Ph.D. Travel Award (Conference Funding)




   Department of Energy #DE-FG52-09NA29451
   (UEM Research Grant)
https://github.com/jberger/YAPCNA2012

    Joel Berger (UIC)      OO Physical Modeling        June 15, 2012   15 / 15

Mais conteúdo relacionado

Destaque

Oracle SQL Developer Data Modeler - Version Control Your Designs
Oracle SQL Developer Data Modeler - Version Control Your DesignsOracle SQL Developer Data Modeler - Version Control Your Designs
Oracle SQL Developer Data Modeler - Version Control Your DesignsJeff Smith
 
Planning and executing a DB2 11 for z/OS Migration by Ian Cook
Planning and executing a DB2 11 for z/OS  Migration  by Ian Cook Planning and executing a DB2 11 for z/OS  Migration  by Ian Cook
Planning and executing a DB2 11 for z/OS Migration by Ian Cook Surekha Parekh
 
Strategies for Distributed Data Storage
Strategies for Distributed Data StorageStrategies for Distributed Data Storage
Strategies for Distributed Data Storagekakugawa
 
Understanding Data Partitioning and Replication in Apache Cassandra
Understanding Data Partitioning and Replication in Apache CassandraUnderstanding Data Partitioning and Replication in Apache Cassandra
Understanding Data Partitioning and Replication in Apache CassandraDataStax
 
5 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/25 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/2Fabio Fumarola
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WPNguyen Tuan
 

Destaque (7)

Physical Modeling and Design for Phase Change Memories
Physical Modeling and Design for Phase Change MemoriesPhysical Modeling and Design for Phase Change Memories
Physical Modeling and Design for Phase Change Memories
 
Oracle SQL Developer Data Modeler - Version Control Your Designs
Oracle SQL Developer Data Modeler - Version Control Your DesignsOracle SQL Developer Data Modeler - Version Control Your Designs
Oracle SQL Developer Data Modeler - Version Control Your Designs
 
Planning and executing a DB2 11 for z/OS Migration by Ian Cook
Planning and executing a DB2 11 for z/OS  Migration  by Ian Cook Planning and executing a DB2 11 for z/OS  Migration  by Ian Cook
Planning and executing a DB2 11 for z/OS Migration by Ian Cook
 
Strategies for Distributed Data Storage
Strategies for Distributed Data StorageStrategies for Distributed Data Storage
Strategies for Distributed Data Storage
 
Understanding Data Partitioning and Replication in Apache Cassandra
Understanding Data Partitioning and Replication in Apache CassandraUnderstanding Data Partitioning and Replication in Apache Cassandra
Understanding Data Partitioning and Replication in Apache Cassandra
 
5 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/25 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/2
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP
 

Semelhante a Modeling Physical Systems with Modern Object Oriented Perl

Linked CP Tensor Decomposition (presented by ICONIP2012)
Linked CP Tensor Decomposition (presented by ICONIP2012)Linked CP Tensor Decomposition (presented by ICONIP2012)
Linked CP Tensor Decomposition (presented by ICONIP2012)Tatsuya Yokota
 
How to improve the statistical power of the 10-fold cross validation scheme i...
How to improve the statistical power of the 10-fold crossvalidation scheme i...How to improve the statistical power of the 10-fold crossvalidation scheme i...
How to improve the statistical power of the 10-fold cross validation scheme i...Andrej Kosir
 
Facial Expression Recognition / Removal
Facial Expression Recognition / RemovalFacial Expression Recognition / Removal
Facial Expression Recognition / RemovalRafael Dahis
 
Aces Verona 07 Foils
Aces Verona 07 FoilsAces Verona 07 Foils
Aces Verona 07 FoilsAntonini
 
Shearlet Frames and Optimally Sparse Approximations
Shearlet Frames and Optimally Sparse ApproximationsShearlet Frames and Optimally Sparse Approximations
Shearlet Frames and Optimally Sparse ApproximationsJakob Lemvig
 
Benchmark Calculations of Atomic Data for Modelling Applications
 Benchmark Calculations of Atomic Data for Modelling Applications Benchmark Calculations of Atomic Data for Modelling Applications
Benchmark Calculations of Atomic Data for Modelling ApplicationsAstroAtom
 
Robotics
RoboticsRobotics
Roboticscenkkk
 
Liom sg talk 2020
Liom sg talk 2020Liom sg talk 2020
Liom sg talk 2020Ze-Yang Li
 
Multivariate Analysis of Cauchy’s Inequality
Multivariate Analysis of Cauchy’s InequalityMultivariate Analysis of Cauchy’s Inequality
Multivariate Analysis of Cauchy’s InequalityIRJET Journal
 
Atomic Structure and Periodicity
Atomic Structure and PeriodicityAtomic Structure and Periodicity
Atomic Structure and PeriodicityLumen Learning
 
Introduction to Common Spatial Pattern Filters for EEG Motor Imagery Classifi...
Introduction to Common Spatial Pattern Filters for EEG Motor Imagery Classifi...Introduction to Common Spatial Pattern Filters for EEG Motor Imagery Classifi...
Introduction to Common Spatial Pattern Filters for EEG Motor Imagery Classifi...Tatsuya Yokota
 
Extended Analysis of Cauchy’s Inequality
Extended Analysis of Cauchy’s InequalityExtended Analysis of Cauchy’s Inequality
Extended Analysis of Cauchy’s InequalityIRJET Journal
 
лекция 1 обзор методов вычислительной физики
лекция 1 обзор методов вычислительной физикилекция 1 обзор методов вычислительной физики
лекция 1 обзор методов вычислительной физикиSergey Sozykin
 
Peridynamic simulation of delamination propagation in fiber-reinforced composite
Peridynamic simulation of delamination propagation in fiber-reinforced compositePeridynamic simulation of delamination propagation in fiber-reinforced composite
Peridynamic simulation of delamination propagation in fiber-reinforced compositeYILE HU
 
A mathematical model for integrating product of two functions
A mathematical model for integrating product of two functionsA mathematical model for integrating product of two functions
A mathematical model for integrating product of two functionsAlexander Decker
 

Semelhante a Modeling Physical Systems with Modern Object Oriented Perl (17)

Linked CP Tensor Decomposition (presented by ICONIP2012)
Linked CP Tensor Decomposition (presented by ICONIP2012)Linked CP Tensor Decomposition (presented by ICONIP2012)
Linked CP Tensor Decomposition (presented by ICONIP2012)
 
presentation1.pdf
presentation1.pdfpresentation1.pdf
presentation1.pdf
 
How to improve the statistical power of the 10-fold cross validation scheme i...
How to improve the statistical power of the 10-fold crossvalidation scheme i...How to improve the statistical power of the 10-fold crossvalidation scheme i...
How to improve the statistical power of the 10-fold cross validation scheme i...
 
Facial Expression Recognition / Removal
Facial Expression Recognition / RemovalFacial Expression Recognition / Removal
Facial Expression Recognition / Removal
 
Aces Verona 07 Foils
Aces Verona 07 FoilsAces Verona 07 Foils
Aces Verona 07 Foils
 
Shearlet Frames and Optimally Sparse Approximations
Shearlet Frames and Optimally Sparse ApproximationsShearlet Frames and Optimally Sparse Approximations
Shearlet Frames and Optimally Sparse Approximations
 
Benchmark Calculations of Atomic Data for Modelling Applications
 Benchmark Calculations of Atomic Data for Modelling Applications Benchmark Calculations of Atomic Data for Modelling Applications
Benchmark Calculations of Atomic Data for Modelling Applications
 
Robotics
RoboticsRobotics
Robotics
 
Liom sg talk 2020
Liom sg talk 2020Liom sg talk 2020
Liom sg talk 2020
 
Multivariate Analysis of Cauchy’s Inequality
Multivariate Analysis of Cauchy’s InequalityMultivariate Analysis of Cauchy’s Inequality
Multivariate Analysis of Cauchy’s Inequality
 
Atomic Structure and Periodicity
Atomic Structure and PeriodicityAtomic Structure and Periodicity
Atomic Structure and Periodicity
 
Introduction to Common Spatial Pattern Filters for EEG Motor Imagery Classifi...
Introduction to Common Spatial Pattern Filters for EEG Motor Imagery Classifi...Introduction to Common Spatial Pattern Filters for EEG Motor Imagery Classifi...
Introduction to Common Spatial Pattern Filters for EEG Motor Imagery Classifi...
 
Extended Analysis of Cauchy’s Inequality
Extended Analysis of Cauchy’s InequalityExtended Analysis of Cauchy’s Inequality
Extended Analysis of Cauchy’s Inequality
 
лекция 1 обзор методов вычислительной физики
лекция 1 обзор методов вычислительной физикилекция 1 обзор методов вычислительной физики
лекция 1 обзор методов вычислительной физики
 
Peridynamic simulation of delamination propagation in fiber-reinforced composite
Peridynamic simulation of delamination propagation in fiber-reinforced compositePeridynamic simulation of delamination propagation in fiber-reinforced composite
Peridynamic simulation of delamination propagation in fiber-reinforced composite
 
A mathematical model for integrating product of two functions
A mathematical model for integrating product of two functionsA mathematical model for integrating product of two functions
A mathematical model for integrating product of two functions
 
Lecture_3.pdf
Lecture_3.pdfLecture_3.pdf
Lecture_3.pdf
 

Último

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Modeling Physical Systems with Modern Object Oriented Perl

  • 1. Modeling Physical Systems with Modern Object Oriented Perl YAPC::NA 2012 Joel Berger University of Illinois at Chicago June 15, 2012 Joel Berger (UIC) OO Physical Modeling June 15, 2012 1 / 15
  • 2. The Problems Physical Simulations Differential Equations A set of rules that define how variables change with some parameter dx x(t2 ) = x(t1 ) + dt ∗ dt Example: Exponential Growth dM = rM =⇒ M (t) = P exp(rt) dt Joel Berger (UIC) OO Physical Modeling June 15, 2012 2 / 15
  • 3. The Problems Physical Simulations Differential Equations A set of rules that define how variables change with some parameter dx x(t2 ) = x(t1 ) + dt ∗ (x, f (t1, t2)) dt Example: Exponential Growth dM = rM =⇒ M (t) = P exp(rt) dt Joel Berger (UIC) OO Physical Modeling June 15, 2012 2 / 15
  • 4. The Problems Physical Simulations Differential Equations A set of rules that define how variables change with some parameter dx x(t2 ) = x(t1 ) + dt ∗ (x, f (t1, t2)) dt Example: Exponential Growth dM = rM =⇒ M (t) = P exp(rt) dt Joel Berger (UIC) OO Physical Modeling June 15, 2012 2 / 15
  • 5. The Problems My Research: Ultrafast Electron Microscopy Joel Berger (UIC) OO Physical Modeling June 15, 2012 3 / 15
  • 6. The Problems My Research: Ultrafast Electron Microscopy Photocathode Magnetic Lenses Detector Joel Berger (UIC) OO Physical Modeling June 15, 2012 3 / 15
  • 7. The Problems My Research: Ultrafast Electron Microscopy Laser Photocathode Magnetic Lenses Detector Joel Berger (UIC) OO Physical Modeling June 15, 2012 3 / 15
  • 8. The Problems My Research: Ultrafast Electron Microscopy Electron Beam Laser Photocathode Magnetic Lenses Detector Joel Berger (UIC) OO Physical Modeling June 15, 2012 3 / 15
  • 9. The Problems My Research: Ultrafast Electron Microscopy RF Cavity Electron Beam Laser Photocathode Magnetic Lenses Detector Joel Berger (UIC) OO Physical Modeling June 15, 2012 3 / 15
  • 10. The Problems The Challenge: A Flexible Interface to a Complex Model Magnetic Lens Magnetic Lens Electron Pulse v = vˆ z w l RF Cavity “z lens” Need: Compute dynamics of electron pulse (w(t), l(t)) Note: Generation and optical elements add terms to DE Want: Representitive OO user-level interface Joel Berger (UIC) OO Physical Modeling June 15, 2012 4 / 15
  • 11. The Problems The Challenge: A Flexible Interface to a Complex Model Magnetic Lens Magnetic Lens Electron Pulse v = vˆ z w l RF Cavity “z lens” Need: Compute dynamics of electron pulse (w(t), l(t)) Note: Generation and optical elements add terms to DE Want: Representitive OO user-level interface Joel Berger (UIC) OO Physical Modeling June 15, 2012 4 / 15
  • 12. The Problems The Challenge: A Flexible Interface to a Complex Model Magnetic Lens Magnetic Lens Electron Pulse v = vˆ z w l RF Cavity “z lens” Need: Compute dynamics of electron pulse (w(t), l(t)) Note: Generation and optical elements add terms to DE Want: Representitive OO user-level interface Joel Berger (UIC) OO Physical Modeling June 15, 2012 4 / 15
  • 13. The Problems The Challenge: A Flexible Interface to a Complex Model Magnetic Lens Magnetic Lens Electron Pulse v = vˆ z w l RF Cavity “z lens” Need: Compute dynamics of electron pulse (w(t), l(t)) Note: Generation and optical elements add terms to DE Want: Representitive OO user-level interface Joel Berger (UIC) OO Physical Modeling June 15, 2012 4 / 15
  • 14. The Problems The “State of the Art” Old codes are lacking full 6D dynamics optimized for performance vs usablilty hard to customize near impossible to comprehend http://laacg.lanl.gov/laacg/services/download_sf.phtml Getting Started with Poisson Superfish . . . We do not recommend trying to build an input file “from scratch.” Instead, find an example file that is similar to the problem you are trying to solve. Make a copy of the file and then make any necessary modifications to the geometry and options. Joel Berger (UIC) OO Physical Modeling June 15, 2012 5 / 15
  • 15. The Problems The “State of the Art” Old codes are lacking full 6D dynamics optimized for performance vs usablilty hard to customize near impossible to comprehend http://laacg.lanl.gov/laacg/services/download_sf.phtml Getting Started with Poisson Superfish . . . We do not recommend trying to build an input file “from scratch.” Instead, find an example file that is similar to the problem you are trying to solve. Make a copy of the file and then make any necessary modifications to the geometry and options. Joel Berger (UIC) OO Physical Modeling June 15, 2012 5 / 15
  • 16. The Problems Other Attempts Modelica: Pros: Mathematica: Open-source, but behind Pros: close-source variants Can solve dynamics Unique OO language for Pretty-printing of math for physical simulation readability Classes have DEs as properties Cons: Cons: Closed-source and expensive! Lacks “has-a” relationship No OO and no key-value Composing DEs not trivial datatypes User-facing object instantiation Still rather slow ∼2mins/sim not trivial Some numerical problems (?) Joel Berger (UIC) OO Physical Modeling June 15, 2012 6 / 15
  • 17. The Problems Other Attempts Modelica: Pros: Mathematica: Open-source, but behind Pros: close-source variants Can solve dynamics Unique OO language for Pretty-printing of math for physical simulation readability Classes have DEs as properties Cons: Cons: Closed-source and expensive! Lacks “has-a” relationship No OO and no key-value Composing DEs not trivial datatypes User-facing object instantiation Still rather slow ∼2mins/sim not trivial Some numerical problems (?) Joel Berger (UIC) OO Physical Modeling June 15, 2012 6 / 15
  • 18. The Problems Other Attempts Modelica: Pros: Mathematica: Open-source, but behind Pros: close-source variants Can solve dynamics Unique OO language for Pretty-printing of math for physical simulation readability Classes have DEs as properties Cons: Cons: Closed-source and expensive! Lacks “has-a” relationship No OO and no key-value Composing DEs not trivial datatypes User-facing object instantiation Still rather slow ∼2mins/sim not trivial Some numerical problems (?) Joel Berger (UIC) OO Physical Modeling June 15, 2012 6 / 15
  • 19. The Problems Other Attempts Modelica: Pros: Mathematica: Open-source, but behind Pros: close-source variants Can solve dynamics Unique OO language for Pretty-printing of math for physical simulation readability Classes have DEs as properties Cons: Cons: Closed-source and expensive! Lacks “has-a” relationship No OO and no key-value Composing DEs not trivial datatypes User-facing object instantiation Still rather slow ∼2mins/sim not trivial Some numerical problems (?) Joel Berger (UIC) OO Physical Modeling June 15, 2012 6 / 15
  • 20. The Problems Other Attempts Modelica: Pros: Mathematica: Open-source, but behind Pros: close-source variants Can solve dynamics Unique OO language for Pretty-printing of math for physical simulation readability Classes have DEs as properties Cons: Cons: Closed-source and expensive! Lacks “has-a” relationship No OO and no key-value Composing DEs not trivial datatypes User-facing object instantiation Still rather slow ∼2mins/sim not trivial Some numerical problems (?) Joel Berger (UIC) OO Physical Modeling June 15, 2012 6 / 15
  • 21. Perl Solution . . . But First, Some Bookkeeping If an object knows where it is, can it remember where it came from? use MooseX::Declare; use Method::Signatures::Modifiers; use MooseX::RememberHistory; class MyClass { use objects as data storage has ’x’ => ( traits => [’RememberHistory’], current data during isa => ’Num’, is => ’rw’, simulation default => 0 all data afterwards ); } works for fixed width solvers my $obj = MyClass->new; adaptive solvers call functions $obj->x( 1 ); repeatedly (i.e. PerlGSL::DiffEq) $obj->x( 2 ); print join ’, ’, @{ $obj->x_history }; # 0, 1, 2 Joel Berger (UIC) OO Physical Modeling June 15, 2012 7 / 15
  • 22. Perl Solution . . . But First, Some Bookkeeping If an object knows where it is, can it remember where it came from? use MooseX::Declare; use Method::Signatures::Modifiers; use MooseX::RememberHistory; class MyClass { use objects as data storage has ’x’ => ( traits => [’RememberHistory’], current data during isa => ’Num’, is => ’rw’, simulation default => 0 all data afterwards ); } works for fixed width solvers my $obj = MyClass->new; adaptive solvers call functions $obj->x( 1 ); repeatedly (i.e. PerlGSL::DiffEq) $obj->x( 2 ); print join ’, ’, @{ $obj->x_history }; # 0, 1, 2 Joel Berger (UIC) OO Physical Modeling June 15, 2012 7 / 15
  • 23. Perl Solution . . . But First, Some Bookkeeping If an object knows where it is, can it remember where it came from? use MooseX::Declare; use Method::Signatures::Modifiers; use MooseX::RememberHistory; class MyClass { use objects as data storage has ’x’ => ( traits => [’RememberHistory’], current data during isa => ’Num’, is => ’rw’, simulation default => 0 all data afterwards ); } works for fixed width solvers my $obj = MyClass->new; adaptive solvers call functions $obj->x( 1 ); repeatedly (i.e. PerlGSL::DiffEq) $obj->x( 2 ); print join ’, ’, @{ $obj->x_history }; # 0, 1, 2 Joel Berger (UIC) OO Physical Modeling June 15, 2012 7 / 15
  • 24. Perl Solution . . . But First, Some Bookkeeping If an object knows where it is, can it remember where it came from? use MooseX::Declare; use Method::Signatures::Modifiers; use MooseX::RememberHistory; class MyClass { use objects as data storage has ’x’ => ( traits => [’RememberHistory’], current data during isa => ’Num’, is => ’rw’, simulation default => 0 all data afterwards ); } works for fixed width solvers my $obj = MyClass->new; adaptive solvers call functions $obj->x( 1 ); repeatedly (i.e. PerlGSL::DiffEq) $obj->x( 2 ); print join ’, ’, @{ $obj->x_history }; # 0, 1, 2 Joel Berger (UIC) OO Physical Modeling June 15, 2012 7 / 15
  • 25. Perl Solution . . . But First, Some Bookkeeping If an object knows where it is, can it remember where it came from? use MooseX::Declare; use Method::Signatures::Modifiers; use MooseX::RememberHistory; class MyClass { use objects as data storage has ’x’ => ( traits => [’RememberHistory’], current data during isa => ’Num’, is => ’rw’, simulation default => 0 all data afterwards ); } works for fixed width solvers my $obj = MyClass->new; adaptive solvers call functions $obj->x( 1 ); repeatedly (i.e. PerlGSL::DiffEq) $obj->x( 2 ); print join ’, ’, @{ $obj->x_history }; # 0, 1, 2 Joel Berger (UIC) OO Physical Modeling June 15, 2012 7 / 15
  • 26. Perl Solution . . . But First, Some Bookkeeping If an object knows where it is, can it remember where it came from? use MooseX::Declare; use Method::Signatures::Modifiers; use MooseX::RememberHistory; class MyClass { use objects as data storage has ’x’ => ( traits => [’RememberHistory’], current data during isa => ’Num’, is => ’rw’, simulation default => 0 all data afterwards ); } works for fixed width solvers my $obj = MyClass->new; adaptive solvers call functions $obj->x( 1 ); repeatedly (i.e. PerlGSL::DiffEq) $obj->x( 2 ); print join ’, ’, @{ $obj->x_history }; # 0, 1, 2 Joel Berger (UIC) OO Physical Modeling June 15, 2012 7 / 15
  • 27. Perl Solution A Simple OO-DE Example Physical Classes use MooseX::RememberHistory; use MooseX::Declare; use Method::Signatures::Modifiers; class MyForce { has ’strength’ => ( isa => ’Num’, is => ’rw’, default => 0 ); has ’affect’ => ( isa => ’CodeRef’, is => ’ro’, required => 1 ); } class MyThing { has ’mass’ => ( isa => ’Num’, is => ’ro’, required => 1 ); has ’x’ => ( traits => [ ’RememberHistory’ ], isa => ’Num’, is => ’rw’, default => 0 ); has ’vx’ => ( traits => [ ’RememberHistory’ ], isa => ’Num’, is => ’rw’, default => 0 ); } Joel Berger (UIC) OO Physical Modeling June 15, 2012 8 / 15
  • 28. Perl Solution A Simple OO-DE Example The Solver: Attributes class MySim { use List::Util ’sum’; has ’start’ => ( isa => ’Num’, is => ’ro’, default => 0 ); has ’end’ => ( isa => ’Num’, is => ’ro’, default => 1 ); has ’steps’ => ( isa => ’Num’, is => ’ro’, default => 100 ); has ’step’ => ( isa => ’Num’, is => ’ro’, lazy => 1, builder => ’init_step’); has ’time’ => ( traits => [ ’RememberHistory’ ], isa => ’Num’, is => ’rw’, lazy => 1, builder => ’init_time’ ); has ’things’ => ( isa => ’ArrayRef[MyThing]’, is => ’rw’, default => sub{[]} ); has ’forces’ => ( isa => ’ArrayRef[MyForce]’, is => ’rw’, default => sub{[]} ); method init_step () { my $step = ($self->end - $self->start) / $self->steps; return $step; } method init_time () { return $self->start } Joel Berger (UIC) OO Physical Modeling June 15, 2012 9 / 15
  • 29. Perl Solution A Simple OO-DE Example The Solver: Methods method evolve ( MyThing $thing ) { my $dt = $self->step; my $vx = $thing->vx; my $force = sum map { $_->affect->($_, $thing) } @{ $self->forces }; my $acc = $force / ($thing->mass); $thing->vx( $vx + $acc * $dt ); $thing->x( $thing->x + $vx * $dt ); } method run () { while ($self->time < $self->end) { $self->evolve( $_ ) for @{ $self->things }; $self->time( $self->time + $self->step ); } } } # end of class MySim Joel Berger (UIC) OO Physical Modeling June 15, 2012 10 / 15
  • 30. Perl Solution A Simple OO-DE Example The Script #!/usr/bin/env perl my $sim = MySim->new( use strict; use warnings; end => 5, use MySim; things => [ $thing ], use PDL; forces => [ $acc, $dec ], use PDL::Graphics::Prima::Simple; ); my $thing = MyThing->new( mass => 2 ); $sim->run; my $acc = MyForce->new( my $time = pdl $sim->time_history; strength => 2, my $x = pdl $thing->x_history; affect => sub {shift->strength}, ); line_plot($time, $x); my $dec = MyForce->new( strength => -30, affect => sub { my ($self, $thing) = @_; return 0 if ($thing->x < 0.1); return $self->strength; }, ); Joel Berger (UIC) OO Physical Modeling June 15, 2012 11 / 15
  • 31. Perl Solution A Simple OO-DE Example The Script #!/usr/bin/env perl my $sim = MySim->new( use strict; use warnings; end => 5, use MySim; things => [ $thing ], use PDL; forces => [ $acc, $dec ], use PDL::Graphics::Prima::Simple; ); my $thing = MyThing->new( mass => 2 ); $sim->run; my $acc = MyForce->new( my $time = pdl $sim->time_history; strength => 2, my $x = pdl $thing->x_history; affect => sub {shift->strength}, ); line_plot($time, $x); my $dec = MyForce->new( strength => -30, affect => sub { my ($self, $thing) = @_; return 0 if ($thing->x < 0.1); return $self->strength; }, ); Joel Berger (UIC) OO Physical Modeling June 15, 2012 11 / 15
  • 32. Units Handling Unit Handling (The Implied Covenant) Mars Surveyor ’98 Orbiter Software used force in Newtons Users entered force in Foot-Pounds The Covenant: Between programmer and user “Use the same units!” Unexpected and possibly undocumented action at a distance With Perl and Moose we can do better . . . Joel Berger (UIC) OO Physical Modeling June 15, 2012 12 / 15
  • 33. Units Handling Unit Handling (The Implied Covenant) Mars Surveyor ’98 Orbiter (Sorry Larry!) Software used force in Newtons Users entered force in Foot-Pounds The Covenant: Between programmer and user “Use the same units!” Unexpected and possibly undocumented action at a distance With Perl and Moose we can do better . . . Joel Berger (UIC) OO Physical Modeling June 15, 2012 12 / 15
  • 34. Units Handling Unit Handling (The Implied Covenant) Mars Surveyor ’98 Orbiter (Sorry Larry!) Software used force in Newtons Users entered force in Foot-Pounds The Covenant: Between programmer and user “Use the same units!” Unexpected and possibly undocumented action at a distance With Perl and Moose we can do better . . . Joel Berger (UIC) OO Physical Modeling June 15, 2012 12 / 15
  • 35. Units Handling Unit Handling (The Implied Covenant) Mars Surveyor ’98 Orbiter (Sorry Larry!) Software used force in Newtons Users entered force in Foot-Pounds The Covenant: Between programmer and user “Use the same units!” Unexpected and possibly undocumented action at a distance With Perl and Moose we can do better . . . Joel Berger (UIC) OO Physical Modeling June 15, 2012 12 / 15
  • 36. Units Handling Unit Handling (The Implied Covenant) Mars Surveyor ’98 Orbiter (Sorry Larry!) Software used force in Newtons Users entered force in Foot-Pounds The Covenant: Between programmer and user “Use the same units!” Unexpected and possibly undocumented action at a distance With Perl and Moose we can do better . . . Joel Berger (UIC) OO Physical Modeling June 15, 2012 12 / 15
  • 37. Units Handling Unit Handling (The Implied Covenant) Mars Surveyor ’98 Orbiter (Sorry Larry!) Software used force in Newtons Users entered force in Foot-Pounds The Covenant: Between programmer and user “Use the same units!” Unexpected and possibly undocumented action at a distance With Perl and Moose we can do better . . . Joel Berger (UIC) OO Physical Modeling June 15, 2012 12 / 15
  • 38. Units Handling MooseX::Types::NumUnit Str to Num coercions convert unit if needed use MooseX::Declare; use Method::Signatures::Modifiers; class SphericalCow { use MooseX::Types::NumUnit qw/num_of_unit/; has ’radius’ => ( isa => num_of_unit(’m’), is => ’rw’, default => 1 ); has ’velocity’ => ( isa => num_of_unit(’m/s’), is => ’rw’, default => 0 ); } use strict; use warnings; my $cow = SphericalCow->new( radius => ’1 ft’, ); print $cow->radius . "n"; # 0.3048 Joel Berger (UIC) OO Physical Modeling June 15, 2012 13 / 15
  • 39. Real World Example Example of Physics::UEMColumn Back to Electron Column Modeling Magnetic Lens Magnetic Lens Electron Pulse v = vˆ z w l RF Cavity “z lens” As yet unreleased Physics::UEMColumn https://github.com/jberger/Physics-UEMColumn Uses: PerlGSL::DiffEq on CPAN C-level solver of Perl-level DE closures Joel Berger (UIC) OO Physical Modeling June 15, 2012 14 / 15
  • 40. Finally Acknowledgements Graduate College Dean’s Fellowship (Major Student Funding) LAS Ph.D. Travel Award (Conference Funding) Department of Energy #DE-FG52-09NA29451 (UEM Research Grant) https://github.com/jberger/YAPCNA2012 Joel Berger (UIC) OO Physical Modeling June 15, 2012 15 / 15