forked from itamblyn/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ps_jeep_to_qbox.pl
executable file
·88 lines (64 loc) · 1.82 KB
/
ps_jeep_to_qbox.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/perl
package main;
$inc = "$ENV{'HOME'}/bin";
#$inc = "$ENV{'HOME'}/qbox";
push(@INC,$inc);
require 'jeep_ps.pm';
require 'xmls_style_io.pm';
#use strict;
#use warnings;
use IO::File;
die qq{Usage: ps_jeep_to_qbox.pl filename\n} unless @ARGV;
$file = shift;
$ps = new jeep_ps($file);
$out = "$file.xml";
$fh = new IO::File;
$fh->open(">$out") or die qq{Could not open $out\n};
$qbox = new xmls_style_io($fh);
$qbox->print_head();
$description = $file;
$description =~ s/_/ /g;
$qbox->xmlprint("description",$description);
@tmp = split(/\s+/,$description);
$elem = shift(@tmp);
$qbox->xmlprint("symbol",$elem);
print "type atomic number: ";
chomp($atomic_number = <STDIN>);
$qbox->xmlprint("atomic_number",$atomic_number);
$qbox->xmlprint("mass",$ps->get_mass());
$qbox->open_brace("norm_conserving_pseudopotential");
$qbox->xmlprint("valence_charge",int($ps->get_num_valence()));
$qbox->xmlprint("lmax",$ps->get_max_l());
$qbox->xmlprint("llocal",$ps->get_l_loc());
$qbox->xmlprint("nquad",$ps->get_nquad());
if ($ps->get_nquad() == 0){
$rquad = 0.0;
}else{
print "type rquad: ";
chop($rquad = <STDIN>);
}
$qbox->xmlprint("rquad",$rquad);
$qbox->xmlprint("mesh_spacing",$ps->get_mesh_spacing());
for($l = 0; $l <= $ps->get_max_l(); $l++){
$mesh = $ps->get_num_grid($l);
$brace = "projector l=\"$l\" size=\"$mesh\"";
$qbox->open_brace($brace);
@pot = $ps->get_ps($l);
# $pot = join("\n",@pot);
# $pot = "";
# foreach(@pot){
# $pot .= " " . $_ . "\n";
# }
$qbox->xmlprint("radial_potential",@pot);
@wf = $ps->get_wavefun($l);
# $wf = "";
# foreach(@wf){
# $wf .= " " . $_ . "\n";
# }
# $wf = join("\n",@wf);
$qbox->xmlprint("radial_function",@wf);
$qbox->close_brace("projector");
}
$qbox->close_brace("norm_conserving_pseudopotential");
$qbox->close_brace("qbox:species");
$fh->close();