HackaMol::X::Calculator - Abstract calculator class for HackaMol
version 0.012
use Modern::Perl; use HackaMol; use HackaMol::X::Calculator; use Path::Tiny; my $path = shift || die "pass path to gaussian outputs"; my $hack = HackaMol->new( data => $path, ); foreach my $out ( $hack->data->children(qr/\.out$/) ) { my $Calc = HackaMol::X::Calculator->new( out_fn => $out, map_out => \&output_map, ); my $energy = $Calc->map_output(627.51); printf( "%-40s: %10.6f\n", $Calc->out_fn->basename, $energy ); } # our function to map molec info from output sub output_map { my $calc = shift; my $conv = shift; my $re = qr/-\d+.\d+/; my @energys = $calc->out_fn->slurp =~ m/SCF Done:.*(${re})/g; return ( $energys[-1] * $conv ); }
The HackaMol::X::Calculator extension generalizes molecular calculations using external programs. The Calculator class consumes the HackaMol::X::Roles::ExtensionRole role, which manage the running of executables... perhaps on files; perhaps in directories. This extension is intended to provide a simple example of interfaces with external programs. This is a barebones use of the ExtensionRole that is intended to be flexible. See the examples and testing directory for use of the map_in and map_out functions inside and outside of the map_input and map_output functions. Extensions with more rigid and encapsulated APIs can evolve from this starting point. In the synopsis, a Gaussian output is processed for the SCF Done value (a classic scripting of problem computational chemists). See the examples and tests to learn how the calculator can be used to:
1. generate inputs 2. run programs 3. process outputs
via interactions with HackaMol objects.
If scratch is set, the object will build that directory if needed. See HackaMol::PathRole for more information about the scratch attribute.
HackaMol
HackaMol::X::Roles::Extension
HackaMol::PathRole
Path::Tiny
Moose::Object
HackaMol::Roles::ExeRole
HackaMol::Roles::PathRole
HackaMol::X::Roles::ExtensionRole
Demian Riccardi <demianriccardi@gmail.com>
This software is copyright (c) 2015 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.
To install HackaMol::X::Calculator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HackaMol::X::Calculator
CPAN shell
perl -MCPAN -e shell install HackaMol::X::Calculator
For more information on module installation, please visit the detailed CPAN module installation guide.