| 1 | package HackaMol::Bond; | ||
| 2 | 12 | $HackaMol::Bond::VERSION = '0.053'; | |
| 3 | #ABSTRACT: HackaMol Bond class | ||
| 4 | 12 | ▶ | use 5.008; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 12 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 12 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 12 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 12 | ▶ | use MooseX::StrictConstructor; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | #use MooseX::Storage; | ||
| 11 | #with Storage( 'io' => 'StorableFile' ), | ||
| 12 | 12 | with 'HackaMol::Roles::NameRole', 'HackaMol::Roles::AtomGroupRole'; | |
| 13 | |||
| 14 | has $_ => ( | ||
| 15 | is => 'rw', | ||
| 16 | isa => 'Num', | ||
| 17 | default => 1, | ||
| 18 | lazy => 1, | ||
| 19 | clearer => 'clear_bond_order', | ||
| 20 | 12 | ) foreach qw(bond_order); | |
| 21 | |||
| 22 | has $_ => ( | ||
| 23 | is => 'rw', | ||
| 24 | isa => 'Num', | ||
| 25 | default => 0, | ||
| 26 | lazy => 1, | ||
| 27 | clearer => "clear_$_", | ||
| 28 | 12 | ) foreach qw(bond_fc bond_length_eq); | |
| 29 | |||
| 30 | 12 | has 'bond_efunc' => ( | |
| 31 | is => 'rw', | ||
| 32 | isa => 'CodeRef', | ||
| 33 | builder => "_build_bond_efunc", | ||
| 34 | lazy => 1, | ||
| 35 | ); | ||
| 36 | |||
| 37 | 1 | ▶ | sub _build_bond_efunc { |
|
Subroutine
_build_bond_efunc: called CC=1 SCAR=0.0
| |||
| 38 | |||
| 39 | #my $self = shift; #self is passed by moose, but we don't use it here | ||
| 40 | 2 | ▶ | my $subref = sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 41 | 2 | my $bond = shift; | |
| 42 | 2 | my $val = ( $bond->bond_length - $bond->bond_length_eq )**2; | |
| 43 | 2 | return ( $bond->bond_fc * $val ); | |
| 44 | 1 | }; | |
| 45 | 1 | return ($subref); | |
| 46 | } | ||
| 47 | |||
| 48 | 22 | ▶ | sub bond_vector { |
|
Subroutine
bond_vector: called CC=1 SCAR=0.0
Pod
documented
| |||
| 49 | 22 | my $self = shift; | |
| 50 | 22 | my @atoms = $self->all_atoms; | |
| 51 | 22 | return ( $atoms[0]->inter_dcoords( $atoms[1] ) ); | |
| 52 | } | ||
| 53 | |||
| 54 | 458 | ▶ | sub bond_length { |
|
Subroutine
bond_length: called CC=1 SCAR=0.0
Pod
documented
| |||
| 55 | 458 | my $self = shift; | |
| 56 | 458 | my @atoms = $self->all_atoms; | |
| 57 | 458 | return ( $atoms[0]->distance( $atoms[1] ) ); | |
| 58 | } | ||
| 59 | |||
| 60 | 3 | ▶ | sub bond_energy { |
|
Subroutine
bond_energy: called CC=1 SCAR=0.0
Pod
documented
| |||
| 61 | 3 | my $self = shift; | |
| 62 | 3 | my $energy = &{ $self->bond_efunc }( $self, @_ ); | |
| 63 | 3 | return ($energy); | |
| 64 | } | ||
| 65 | |||
| 66 | 12 | __PACKAGE__->meta->make_immutable; | |
| 67 | |||
| 68 | 12 | 1; | |
| 69 | |||
| 70 | __END__ | ||