NAME

HackaMol::Angle - Angle class for HackaMol

VERSION

version 0.00_19

SYNOPSIS

use HackaMol::Atom;
use HackaMol::Angle;

my $atom1 = HackaMol::Atom->new(
    name    => 'O1',
    coords  => [ V( 2.05274, 0.01959, -0.07701 ) ],
    Z       => 8,
);

my $atom2 = HackaMol::Atom->new(
    name    => 'H1',
    coords  => [ V( 1.08388, 0.02164, -0.12303 ) ],
    Z       => 1,
);

my $atom3 = HackaMol::Atom->new(
    name    => 'H2',
    coords  => [ V( 2.33092, 0.06098, -1.00332 ) ],
    Z       => 1,
);

my $angle1 = HackaMol::Angle->new(name=>'OH2', atoms=>[$atom1,$atom2,$atom3]);
my $angle2 = HackaMol::Angle->new(name=>'OH2', atoms=>[$atom2,$atom1,$atom3]);

foreach my $angle ($angle1, $angle2){
  my $pangle = sprintf(
                "Angle: %s, angle: %.2f, vector normal to angle plane: %.5 %.5 %.5 \n",
                $angle->name, 
                $angle->ang, 
                @{$angle->ang_normvec},
  );
  print $pangle;
}

my @COM_ats = map {HackaMol::Atom->new(
                      name    => "X".$_->name."X",
                      coords  => [ $_->COM ],
                      Z       => 1)
                  }($angle1, $angle2);

my @ang_w_HH = grep { $_->get_atoms(0)->Z == 1 and
                      $_->get_atoms(1)->Z == 1} ($angle1, $angle2);

DESCRIPTION

The HackaMol Angle class provides a set of methods and attributes for working with two connections between three atoms. Like the Bond, the Angle class consumes the AtomGroupRole providing methods to determine the center of mass, total charge, etc (see HackaMol::AtomGroupRole). An Angle containing (atom1,atom2,atom3) produce angles between the atom21 atom23 interatomic vectors.

The Angle class also provides attributes and methods to set force_constants and measure energy. The angle_energy method calls on a CodeRef attribute that the user may define. See descriptions below.

METHODS

ang_normvec

no arguments. returns Math::Vector::Real (MVR) object from the normalized cross product of the atom21 and atom23 interatomic vectors.

bisector

no arguments. returns vector (MVR) that bisects the angle between the two vectors of the angle.

ang_deg

no arguments. returns the angle (degrees) between the atom21 and atom23 vectors.

ang_rad

no arguments. returns the angle (radians) between the atom21 and atom23 vectors.

angle_energy

arguments, as many as you want. Calculates energy using the angle_energy_func described below, if the attribute, angle_fc > 0. The angle_energy method calls the angle_energy_func as follows:

my $energy = &{$self->angle_energy_func}($self,@_);

which will pass $self and that in @_ array to angle_energy_func, which, similar to the Bond class, can be redefined.

ATTRIBUTES

name

isa Str that is lazy and rw. useful for labeling, bookkeeping...

angle_fc

isa Num that is lazy and rw. default = 0. force constant for harmonic potentials.

ang_eq

isa Num that is lazy and rw. default = 0. Equilibrium angle. The ang method returns angle in degrees.

angle_energy_func

isa CodeRef that is lazy and rw. default uses builder to generate harmonic potential from the angle_fc, ang_eq, and ang. See the _build_angle_energy_func, if interested in changing the function form.

SEE ALSO

EXTENDS

CONSUMES

AUTHOR

Demian Riccardi <demianriccardi@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Demian Riccardi.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.