| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
$HackaMol::Bond::VERSION = '0.053'; |
|
2
|
|
|
|
|
|
|
#ABSTRACT: HackaMol Bond class |
|
3
|
|
|
|
|
|
|
use 5.008; |
|
4
|
12
|
|
|
12
|
|
873
|
use Moose; |
|
|
12
|
|
|
|
|
41
|
|
|
5
|
12
|
|
|
12
|
|
62
|
use namespace::autoclean; |
|
|
12
|
|
|
|
|
22
|
|
|
|
12
|
|
|
|
|
93
|
|
|
6
|
12
|
|
|
12
|
|
69829
|
use Carp; |
|
|
12
|
|
|
|
|
28
|
|
|
|
12
|
|
|
|
|
128
|
|
|
7
|
12
|
|
|
12
|
|
991
|
use MooseX::StrictConstructor; |
|
|
12
|
|
|
|
|
26
|
|
|
|
12
|
|
|
|
|
909
|
|
|
8
|
12
|
|
|
12
|
|
74
|
|
|
|
12
|
|
|
|
|
22
|
|
|
|
12
|
|
|
|
|
94
|
|
|
9
|
|
|
|
|
|
|
#use MooseX::Storage; |
|
10
|
|
|
|
|
|
|
#with Storage( 'io' => 'StorableFile' ), |
|
11
|
|
|
|
|
|
|
with 'HackaMol::Roles::NameRole', 'HackaMol::Roles::AtomGroupRole'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has $_ => ( |
|
14
|
|
|
|
|
|
|
is => 'rw', |
|
15
|
|
|
|
|
|
|
isa => 'Num', |
|
16
|
|
|
|
|
|
|
default => 1, |
|
17
|
|
|
|
|
|
|
lazy => 1, |
|
18
|
|
|
|
|
|
|
clearer => 'clear_bond_order', |
|
19
|
|
|
|
|
|
|
) foreach qw(bond_order); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has $_ => ( |
|
22
|
|
|
|
|
|
|
is => 'rw', |
|
23
|
|
|
|
|
|
|
isa => 'Num', |
|
24
|
|
|
|
|
|
|
default => 0, |
|
25
|
|
|
|
|
|
|
lazy => 1, |
|
26
|
|
|
|
|
|
|
clearer => "clear_$_", |
|
27
|
|
|
|
|
|
|
) foreach qw(bond_fc bond_length_eq); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'bond_efunc' => ( |
|
30
|
|
|
|
|
|
|
is => 'rw', |
|
31
|
|
|
|
|
|
|
isa => 'CodeRef', |
|
32
|
|
|
|
|
|
|
builder => "_build_bond_efunc", |
|
33
|
|
|
|
|
|
|
lazy => 1, |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#my $self = shift; #self is passed by moose, but we don't use it here |
|
38
|
|
|
|
|
|
|
my $subref = sub { |
|
39
|
|
|
|
|
|
|
my $bond = shift; |
|
40
|
|
|
|
|
|
|
my $val = ( $bond->bond_length - $bond->bond_length_eq )**2; |
|
41
|
2
|
|
|
2
|
|
3
|
return ( $bond->bond_fc * $val ); |
|
42
|
2
|
|
|
|
|
5
|
}; |
|
43
|
2
|
|
|
|
|
38
|
return ($subref); |
|
44
|
1
|
|
|
1
|
|
6
|
} |
|
45
|
1
|
|
|
|
|
24
|
|
|
46
|
|
|
|
|
|
|
my $self = shift; |
|
47
|
|
|
|
|
|
|
my @atoms = $self->all_atoms; |
|
48
|
|
|
|
|
|
|
return ( $atoms[0]->inter_dcoords( $atoms[1] ) ); |
|
49
|
22
|
|
|
22
|
1
|
34
|
} |
|
50
|
22
|
|
|
|
|
792
|
|
|
51
|
22
|
|
|
|
|
74
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
my @atoms = $self->all_atoms; |
|
53
|
|
|
|
|
|
|
return ( $atoms[0]->distance( $atoms[1] ) ); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
458
|
|
|
458
|
1
|
1578
|
|
|
56
|
458
|
|
|
|
|
10760
|
my $self = shift; |
|
57
|
458
|
|
|
|
|
843
|
my $energy = &{ $self->bond_efunc }( $self, @_ ); |
|
58
|
|
|
|
|
|
|
return ($energy); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
3
|
|
|
3
|
1
|
5
|
__PACKAGE__->meta->make_immutable; |
|
62
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
64
|
|
|
63
|
3
|
|
|
|
|
16
|
1; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=pod |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
HackaMol::Bond - HackaMol Bond class |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
version 0.053 |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
use HackaMol::Atom; |
|
79
|
|
|
|
|
|
|
use HackaMol::Bond; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $atom1 = HackaMol::Atom->new( |
|
82
|
|
|
|
|
|
|
name => 'O1', |
|
83
|
|
|
|
|
|
|
coords => [ V( 2.05274, 0.01959, -0.07701 ) ], |
|
84
|
|
|
|
|
|
|
Z => 8, |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $atom2 = HackaMol::Atom->new( |
|
88
|
|
|
|
|
|
|
name => 'H1', |
|
89
|
|
|
|
|
|
|
coords => [ V( 1.08388, 0.02164, -0.12303 ) ], |
|
90
|
|
|
|
|
|
|
Z => 1, |
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $atom3 = HackaMol::Atom->new( |
|
94
|
|
|
|
|
|
|
name => 'H2', |
|
95
|
|
|
|
|
|
|
coords => [ V( 2.33092, 0.06098, -1.00332 ) ], |
|
96
|
|
|
|
|
|
|
Z => 1, |
|
97
|
|
|
|
|
|
|
); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $bond1 = HackaMol::Bond->new(name=>'O1H1', atoms=>[$atom1,$atom2]); |
|
100
|
|
|
|
|
|
|
my $bond2 = HackaMol::Bond->new(name=>'O1H2', atoms=>[$atom1,$atom3]); |
|
101
|
|
|
|
|
|
|
my $bond3 = HackaMol::Bond->new(name=>'H1H2', atoms=>[$atom2,$atom3]); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my @bonds = ($bond1, $bond2, $bond3); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
foreach my $bond ( @bonds ){ |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $pbond = sprintf( |
|
108
|
|
|
|
|
|
|
"Bond: %s, Length: %.2f, Vector: %.5 %.5 %.5 \n", |
|
109
|
|
|
|
|
|
|
$bond->name, |
|
110
|
|
|
|
|
|
|
$bond->bond_length, |
|
111
|
|
|
|
|
|
|
@{$bond->bond_vector}, |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
print $pbond; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my @COM_ats = map {HackaMol::Atom->new( |
|
120
|
|
|
|
|
|
|
name => "X".$_->name."X", |
|
121
|
|
|
|
|
|
|
coords => [ $_->COM ], |
|
122
|
|
|
|
|
|
|
Z => 1, |
|
123
|
|
|
|
|
|
|
) |
|
124
|
|
|
|
|
|
|
} @bonds; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my @HH_bonds = grep { $_->get_atoms(0)->Z == 1 and |
|
127
|
|
|
|
|
|
|
$_->get_atoms(1)->Z == 1} @bonds; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
The HackaMol Bond class provides a set of methods and attributes for working |
|
132
|
|
|
|
|
|
|
with connections between two atoms. The Bond class consumes the |
|
133
|
|
|
|
|
|
|
AtomGroupRole providing Bond objects with methods to determine the center of |
|
134
|
|
|
|
|
|
|
mass, total charge, etc (see L<HackaMol::AtomGroupRole>). |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The Bond class also provides attributes and methods to set force_constants and |
|
137
|
|
|
|
|
|
|
measure energy. The bond_energy method calls on a CodeRef attribute that the |
|
138
|
|
|
|
|
|
|
user may define. See descriptions below. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 METHODS |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 bond_vector |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
no arguments. returns Math::Vector::Real object from |
|
145
|
|
|
|
|
|
|
$atoms[0]->inter_dcoords($atoms[1]) for the two atoms in the bond. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 bond_length |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
no arguments. returns $atoms[0]->distance($atoms[1]) for the two atoms in |
|
150
|
|
|
|
|
|
|
the bond. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 bond_energy |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
arguments, as many as you want. Calculates energy using the bond_efunc |
|
155
|
|
|
|
|
|
|
described below, if the attribute, bond_fc > 0. The bond_energy method calls |
|
156
|
|
|
|
|
|
|
the bond_efunc as follows: |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
my $energy = &{$self->bond_efunc}($self,@_); |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
which will pass $self and that in @_ array to bond_efunc, which can be |
|
161
|
|
|
|
|
|
|
redefined. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 atoms |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
isa ArrayRef[Atom] that is lazy with public ARRAY traits provided by the AtomGroupRole (see documentation for more details). |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Pushing (atom1, atom2) on to the Bond object will produce bond_length and bond_vector from atom1 to atom2 (the atom12 interatomic vector). |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 name |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
isa Str that is lazy and rw. useful for labeling, bookkeeping... |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 bond_order |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
isa Num that is lazy and rw. default = 1, single bond. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 bond_fc |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
isa Num that is lazy and rw. default = 0. force constant for harmonic bond |
|
182
|
|
|
|
|
|
|
potentials. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 bond_length_eq |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
isa Num that is lazy and rw. default = 0. Equilibrium bond length. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 bond_efunc |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
isa CodeRef that is lazy and rw. default uses builder to generate harmonic |
|
191
|
|
|
|
|
|
|
potential from the bond_fc, bond_length_eq, and bond_length. See the |
|
192
|
|
|
|
|
|
|
_build_bond_efunc, if interested in changing the function form. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=over 4 |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item * |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
L<HackaMol::AtomGroupRole> |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
L<HackaMol::Angle> |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
L<HackaMol::Dihedral> |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item * |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
L<Chemistry::Bond> |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=back |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 EXTENDS |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=over 4 |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item * L<Moose::Object> |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=back |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 CONSUMES |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over 4 |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::AtomGroupRole> |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::NameRole> |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::NameRole|HackaMol::Roles::AtomGroupRole> |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=back |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 AUTHOR |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Demian Riccardi <demianriccardi@gmail.com> |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Demian Riccardi. |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
245
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |