@@ -27,13 +27,14 @@ def __init__(self, filename='INCAR'):
2727 filename string, name of INCAR file
2828 ============ =======================================
2929 """
30- VasPy .__init__ (self , filename )
30+ super (self .__class__ , self ).__init__ (filename )
31+ self .__filename = filename
3132 self .load ()
3233
3334 def load (self ):
3435 "Load all data in INCAR."
3536 tot_pnames , tot_datas = [], []
36- with open (self .filename , 'r' ) as f :
37+ with open (self .__filename , 'r' ) as f :
3738 for line in f :
3839 matched = self .rdata (line )
3940 if matched :
@@ -43,10 +44,22 @@ def load(self):
4344 # set attrs
4445 for pname , data in zip (tot_pnames , tot_datas ):
4546 setattr (self , pname , data )
46- self .pnames = tot_pnames
47+ self .__pnames = tot_pnames
4748
4849 return
4950
51+ def pnames (self ):
52+ """
53+ Query function for all parameter names.
54+ """
55+ return self .__pnames
56+
57+ def file_name (self ):
58+ """
59+ Query function for all INCAR path names.
60+ """
61+ return self .__filename
62+
5063 @staticmethod
5164 def rdata (line ):
5265 "Get INCAR data(s) in a line."
@@ -75,7 +88,7 @@ def rdata(line):
7588
7689 def set (self , pname , data ):
7790 """
78- Set a named property of InCar object.
91+ Set a named parameter of InCar object.
7992
8093 Example:
8194 --------
@@ -89,7 +102,7 @@ def set(self, pname, data):
89102
90103 def add (self , pname , data ):
91104 """
92- Add a new property name to InCar object.
105+ Add a new parameter name to InCar object.
93106
94107 Example:
95108 --------
@@ -100,20 +113,20 @@ def add(self, pname, data):
100113 print ("Waring: %s is already in INCAR, " +
101114 "set to %s" % (pname , data ))
102115 else :
103- self .pnames .append (pname )
116+ self .__pnames .append (pname )
104117 setattr (self , pname , data )
105118
106119 return
107120
108121 def tofile (self ):
109122 "Create INCAR file."
110123 content = '# Created by VASPy\n '
111- for pname in self .pnames :
124+ for pname in self .__pnames :
112125 if not hasattr (self , pname ):
113126 raise ValueError ('Unknown parameter: %s' % pname )
114127 data = str (getattr (self , pname ))
115128 content += '%s = %s\n ' % (pname , data )
116- with open ('INCAR' , 'w' ) as f :
129+ with open (self . __filename , 'w' ) as f :
117130 f .write (content )
118131
119132 return
0 commit comments