#!/usr/bin/perl

use strict;
use lib 'd:/Programs/Perl/lib';
use Sci::ChemicalReaction;
use Sci qw($NA);

my $Outfile  = 'MXDInput.in';
my $compound = "(InGaZnO4)30";
my $density  = 6.0; # g/cm3

my $R = new ChemicalReaction;

my ($pElement, $pnElement) = $R->CompoundToElements($compound);
for(my $i = 0 ; $i < @$pElement ; $i++) {
	my $element = $pElement->[$i];
	my $ne      = $pnElement->[$i];
print "  $ne * $element + ";
}

my $MW = $R->MolecularWeight($compound);
print "MW=$MW\n";
print "NA=$NA\n";
my $V = ($MW / $NA) / $density;
print "V=$V cm3 = ", $V * 1.0e24, " A3\n";
my $a = $V**(1.0/3.0) * 1e8;
print "a=$a A\n";

my $rand = int(rand(1000));

print "Create [$Outfile]\n";
open(OUT, ">$Outfile") or "Error: $!: Can not write to [$Outfile]\n";

print OUT<<EOT;
CHAOS
$rand
$compound
 O   ZN   IN   HF   
   30   30   30  120 
    12.000    12.000    12.000
y
1
1
  300.00
y
EOT

close(OUT);
