| 1 | package HackaMol::AtomGroup; | ||||||||||
| 2 | 14 | $HackaMol::AtomGroup::VERSION = '0.051'; | |||||||||
| 3 | #ABSTRACT: HackaMol AtomGroup class | ||||||||||
| 4 | 14 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 14 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 14 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 14 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 14 | ▶ | use MooseX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | #use MooseX::Storage; | ||||||||||
| 11 | #with Storage( 'io' => 'StorableFile' ), | ||||||||||
| 12 | 14 | with 'HackaMol::Roles::NameRole', | |||||||||
| 13 | 'HackaMol::Roles::AtomGroupRole', | ||||||||||
| 14 | 'HackaMol::Roles::SelectionRole'; | ||||||||||
| 15 | |||||||||||
| 16 | sub Rg { | ||||||||||
| 17 | |||||||||||
| 18 | #radius of gyration. | ||||||||||
| 19 | 8 | ▶ | my $self = shift; | ||||||||
|
Subroutine
Rg: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 20 | 8 | ▶ | return (0) unless ( $self->count_atoms ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 7 | my @atoms = $self->all_atoms; | |||||||||
| 22 | 7 | my $com = $self->COM; | |||||||||
| 23 | 7 | my $total_mass = $self->total_mass; | |||||||||
| 24 | 7 | my @masses = map { $_->mass } @atoms; | |||||||||
| 25 | 7 | my @dvec2 = map { $_ * $_ } map { $_->get_coords( $_->t ) - $com } @atoms; | |||||||||
| 26 | 7 | my $sum = 0; | |||||||||
| 27 | 7 | $sum += $masses[$_] * $dvec2[$_] foreach 0 .. $#dvec2; | |||||||||
| 28 | 7 | return ( sqrt( $sum / $total_mass ) ); | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 14 | __PACKAGE__->meta->make_immutable; | |||||||||
| 32 | |||||||||||
| 33 | 14 | 1; | |||||||||
| 34 | |||||||||||
| 35 | __END__ | ||||||||||
| 36 | |||||||||||
| 37 | =pod | ||||||||||
| 38 | |||||||||||
| 39 | =head1 NAME | ||||||||||
| 40 | |||||||||||
| 41 | HackaMol::AtomGroup - HackaMol AtomGroup class | ||||||||||
| 42 | |||||||||||
| 43 | =head1 VERSION | ||||||||||
| 44 | |||||||||||
| 45 | version 0.051 | ||||||||||
| 46 | |||||||||||
| 47 | =head1 SYNOPSIS | ||||||||||
| 48 | |||||||||||
| 49 | use HackaMol::AtomGroup; | ||||||||||
| 50 | use Math::Vector::Real; | ||||||||||
| 51 | use Math::Vector::Real::Random; | ||||||||||
| 52 | |||||||||||
| 53 | my $radius = 16; | ||||||||||
| 54 | my $natoms = int(0.0334*($radius**3)*4*pi/3); | ||||||||||
| 55 | |||||||||||
| 56 | my @atoms = map {Atom->new(Z => 8, charges=> [0], coords => [$_]) } | ||||||||||
| 57 | map {$_*$radius} | ||||||||||
| 58 | map {Math::Vector::Real->random_in_sphere(3)} 1 .. $natoms; | ||||||||||
| 59 | |||||||||||
| 60 | my $group = AtomGroup->new(gname => 'biggroup', atoms=> [@atoms]); | ||||||||||
| 61 | |||||||||||
| 62 | print $group->count_atoms . "\n"; | ||||||||||
| 63 | |||||||||||
| 64 | print $group->count_unique_atoms . "\n"; | ||||||||||
| 65 | |||||||||||
| 66 | print $group->Rg . "\n"; | ||||||||||
| 67 | |||||||||||
| 68 | my $numerical_error = $radius*sqrt($radius*3/5) - $group->Rg; | ||||||||||
| 69 | |||||||||||
| 70 | =head1 DESCRIPTION | ||||||||||
| 71 | |||||||||||
| 72 | The HackaMol AtomGroup class provides methods and attributes for groups of atoms. | ||||||||||
| 73 | Atom groupings can be defined to mimic conventional forcefields or manipulated to | ||||||||||
| 74 | generate novel analytical tools. For example, with a trajectory loaded, a dynamic | ||||||||||
| 75 | cluster of atoms can be placed in a group and monitored in time. Or, perhaps, track | ||||||||||
| 76 | regional charges of a quantum mechanical molecule with changes in configuration or | ||||||||||
| 77 | external field. The AtomGroup class consumes the AtomGroupRole and provides the | ||||||||||
| 78 | parent class for the Molecule class. | ||||||||||
| 79 | |||||||||||
| 80 | =head1 METHODS | ||||||||||
| 81 | |||||||||||
| 82 | =head2 Rg | ||||||||||
| 83 | |||||||||||
| 84 | no arguments. returns the scalar radius of gyration for the group of atoms | ||||||||||
| 85 | |||||||||||
| 86 | =head1 ATTRIBUTES | ||||||||||
| 87 | |||||||||||
| 88 | =head2 name | ||||||||||
| 89 | |||||||||||
| 90 | isa Str that is lazy and rw. useful for labeling, bookkeeping... | ||||||||||
| 91 | |||||||||||
| 92 | =head1 SEE ALSO | ||||||||||
| 93 | |||||||||||
| 94 | =over 4 | ||||||||||
| 95 | |||||||||||
| 96 | =item * | ||||||||||
| 97 | |||||||||||
| 98 | L<HackaMol::Molecule> | ||||||||||
| 99 | |||||||||||
| 100 | =item * | ||||||||||
| 101 | |||||||||||
| 102 | L<HackaMol::AtomGroupRole> | ||||||||||
| 103 | |||||||||||
| 104 | =back | ||||||||||
| 105 | |||||||||||
| 106 | =head1 EXTENDS | ||||||||||
| 107 | |||||||||||
| 108 | =over 4 | ||||||||||
| 109 | |||||||||||
| 110 | =item * L<Moose::Object> | ||||||||||
| 111 | |||||||||||
| 112 | =back | ||||||||||
| 113 | |||||||||||
| 114 | =head1 CONSUMES | ||||||||||
| 115 | |||||||||||
| 116 | =over 4 | ||||||||||
| 117 | |||||||||||
| 118 | =item * L<HackaMol::Roles::AtomGroupRole> | ||||||||||
| 119 | |||||||||||
| 120 | =item * L<HackaMol::Roles::NameRole> | ||||||||||
| 121 | |||||||||||
| 122 | =item * L<HackaMol::Roles::NameRole|HackaMol::Roles::AtomGroupRole|HackaMol::Roles::SelectionRole> | ||||||||||
| 123 | |||||||||||
| 124 | =item * L<HackaMol::Roles::SelectionRole> | ||||||||||
| 125 | |||||||||||
| 126 | =back | ||||||||||
| 127 | |||||||||||
| 128 | =head1 AUTHOR | ||||||||||
| 129 | |||||||||||
| 130 | Demian Riccardi <demianriccardi@gmail.com> | ||||||||||
| 131 | |||||||||||
| 132 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 133 | |||||||||||
| 134 | This software is copyright (c) 2017 by Demian Riccardi. | ||||||||||
| 135 | |||||||||||
| 136 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 137 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 138 | |||||||||||
| 139 | =cut | ||||||||||