| 1 | package Physics::UEMColumn::MagneticLens; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | use namespace::autoclean; | ||
| 5 | |||
| 6 | BEGIN { extends 'Physics::UEMColumn::Element'; } | ||
| 7 | |||
| 8 | use Method::Signatures; | ||
| 9 | |||
| 10 | has 'strength' => ( isa => 'Num', is => 'rw', required => 0); | ||
| 11 | has 'order' => ( isa => 'Int', is => 'ro', default => 1); | ||
| 12 | |||
| 13 | method effect () { | ||
| 14 | |||
| 15 | my $lens_z = $self->location; | ||
| 16 | my $lens_length = $self->length; | ||
| 17 | my $lens_str = $self->strength; | ||
| 18 | my $lens_order = $self->order; | ||
| 19 | |||
| 20 | my $cutoff = $self->cutoff; | ||
| 21 | |||
| 22 | my $code = sub { | ||
| 23 | my ($t, $pulse_z, $pulse_v) = @_; | ||
| 24 | |||
| 25 | my $prox = ($pulse_z - $lens_z) / ( $lens_length / 2 ); | ||
| 26 | if (abs($prox) > $cutoff) { | ||
| 27 | return 0; | ||
| 28 | } | ||
| 29 | |||
| 30 | return $lens_str * exp( - $prox**(2 * $lens_order) ); | ||
| 31 | |||
| 32 | }; | ||
| 33 | |||
| 34 | return {M_t => $code}; | ||
| 35 | |||
| 36 | } | ||
| 37 | |||
| 38 | __PACKAGE__->meta->make_immutable; | ||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | =head1 NAME | ||
| 43 | |||
| 44 | Physics::UEMColumn::MagneticLens - A class representing a magnetic lens in a UEM system | ||
| 45 | |||
| 46 | =head1 SYNOPSIS | ||
| 47 | |||
| 48 | use Physics::UEMColumn alias => ':standard'; | ||
| 49 | my $lens = MagneticLens->new( | ||
| 50 | location => $position . 'cm', | ||
| 51 | length => $length . 'cm', | ||
| 52 | strength => $strength, | ||
| 53 | ); | ||
| 54 | |||
| 55 | =head1 DESCRIPTION | ||
| 56 | |||
| 57 | L<Physics::UEMColumn::MagneticLens> is a class representing a magnetic lens in a UEM system. It is a subclass of L<Physics::UEMColumn::Element> and inherits its attributes and methods. Additionally it provides: | ||
| 58 | |||
| 59 | =head1 ATTRIBUTES | ||
| 60 | |||
| 61 | =over | ||
| 62 | |||
| 63 | =item C<stength> | ||
| 64 | |||
| 65 | Quantifies the strength of the magnetic lens. While this number is conceptually analytical, in practice this number is very hard to determine other than by comparison to lens in question. With this in mind, no unit is used on this attribute. | ||
| 66 | |||
| 67 | =item C<order> | ||
| 68 | |||
| 69 | The super-Gaussian order C<exp( - $x ** ( 2 * $order ) )> determining the shape of the lens. Default is C<1> (a Gaussian). | ||
| 70 | |||
| 71 | =back | ||
| 72 | |||
| 73 | =head1 METHODS | ||
| 74 | |||
| 75 | =over | ||
| 76 | |||
| 77 | =item C<effect> | ||
| 78 | |||
| 79 | Returns a hash reference of effect subroutine references (C<M_t>). See L<Physics::UEMColumn::Element/METHODS> for more. | ||
| 80 | |||
| 81 | =back | ||
| 82 | |||
| 83 | =head1 SOURCE REPOSITORY | ||
| 84 | |||
| 85 | L<http://github.com/jberger/Physics-UEMColumn> | ||
| 86 | |||
| 87 | =head1 AUTHOR | ||
| 88 | |||
| 89 | Joel Berger, E<lt>joel.a.berger@gmail.comE<gt> | ||
| 90 | |||
| 91 | =head1 COPYRIGHT AND LICENSE | ||
| 92 | |||
| 93 | Copyright (C) 2012-2013 by Joel Berger | ||
| 94 | |||
| 95 | This library is free software; you can redistribute it and/or modify | ||
| 96 | it under the same terms as Perl itself. | ||
| 97 |