ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/validation/comp_md.py
(Generate patch)

Comparing branches/development/validation/comp_md.py (file contents):
Revision 1661 by chuckv, Mon Nov 7 13:05:14 2011 UTC vs.
Revision 1662 by chuckv, Mon Nov 7 16:30:29 2011 UTC

# Line 27 | Line 27 | def setupDirectories():
27          logger = logging.getLogger("tcpserver")
28          dir_base = os.getcwd()
29          if(os.path.isfile("../build/bin/openmd")):
30 <                os.chdir("../build/bin/")
31 <                dir_openmd = os.getcwd()
32 <                os.chdir(dir_base)
30 >                dir_openmd = os.path.abspath("../build/bin/openmd")
31          elif(os.path.isfile("../bin/openmd")):
32 <                os.chdir("../bin/")
35 <                dir_openmd = os.getcwd()
36 <                os.chdir(dir_base)      
32 >                dir_openmd = os.path.abspath("../bin/openmd")
33          else:
34                  logger.error("OpenMD : %s", "openmd executable not found at the expected location. Script Will Quit...")
35                  sys.exit()
# Line 142 | Line 138 | Function compares two files.
138   """
139   Function compares two files.
140   @author Samuel Njoroge and ().
141 < @param string fExpected - name of the expected file.
142 < @param string fNew - name of the new test file.
141 > @param string fExpected - name of the validation file.
142 > @param string fNew - name of the file to validate.
143   @param float epsilon - Precision of the comparison of the files.
144   @param boolean ignore_sign - if sign will be a factor in comparing the digits.
145   @return boolean
# Line 230 | Line 226 | def runMdFiles():
226          global dir_base, dir_openmd, dir_cwd
227          output = []
228          for x in range(0, len(fmd_list)):
233                #subprocess.call(["export FORCE_PARAM_PATH=/Users/snjoroge/Documents/openmd/development/forceFields"])
229                  if "argon" in fmd_list[x]:
230                          logger.debug("Switching to Directory: %s", os.path.dirname(fmd_list[x]))
231                          os.chdir(os.path.dirname(fmd_list[x]))
232                          logger.debug("Running: %s", fmd_list[x])
233                          output = subprocess.call([dir_openmd + "/openmd", fmd_list[x]])
234 <                        if(os.path.exists(os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".stat")):
234 >                        if(os.path.exists(os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".stat") and os.path.exists(os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + "_v.stat")):
235                                  #print "Renaming File: " + fmd_base_list[x] + ".stat - " + fmd_base_list[x] + "_v.stat"
236                                  #subprocess.call(["cp", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".stat", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + "_v.stat"])
237                                  logger.debug("Comparing: %s", "Comparing: " + fmd_base_list[x] + ".stat <=> " + fmd_base_list[x] + "_v.stat")
238                                  if(compare(os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".stat", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + "_v.stat")):
239 <                                        logger.warning("Files: %s", "Files do not match.")
239 >                                        logger.warning("Files: Files do not match.")
240                                  else:
241                                          logger.debug("Files Match")
242 +                        else:
243 +                                logger.warning("Stat Files: one of the files was not found: %s \n %s", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".stat", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + "_v.stat")
244 +                                
245 +                        if(os.path.exists(os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".eor") and os.path.exists(os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + "_v.eor")):
246 +                                #print "Renaming File: " + fmd_base_list[x] + ".stat - " + fmd_base_list[x] + "_v.stat"
247 +                                #subprocess.call(["cp", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".stat", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + "_v.stat"])
248 +                                logger.debug("Comparing: %s", "Comparing: " + fmd_base_list[x] + ".eor <=> " + fmd_base_list[x] + "_v.eor")
249 +                                if(compare(os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".eor", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + "_v.eor")):
250 +                                        logger.warning("Files: Files do not match.")
251 +                                else:
252 +                                        logger.debug("Files Match")
253 +                        else:
254 +                                logger.warning("Eor Files: one of the files was not found: %s \n %s", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".eor", os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + "_v.eor")
255                  os.chdir(dir_base)
256  
257   def cleanUp():
# Line 258 | Line 266 | def cleanUp():
266                  if(os.path.exists(os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".dump")):
267                          print "DELETE:" + os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".dump"
268                          os.remove(os.path.dirname(fmd_list[x]) + "/" + fmd_base_list[x] + ".dump")
269 +
270 + """
271 + Function compares .eor files. It compares sections <StuntDoubles> for position and section <FrameData> for time.
272 + @author Samuel Njoroge and Dr. Charles Vardeman
273 + @param string file_validate - name of the validation file.
274 + @param string file_validate - name of the file to validate.
275 + @param float epsilon - Precision of the comparison of the files.
276 + @param boolean ignore_sign - if sign will be a factor in comparing the digits.
277 + @return boolean
278 + """
279 + def compareEor(file_validate, file_new, epsilon = 0.00001, ignore_sign=False):
280 +        logger = logging.getLogger("tcpserver")
281 +        handlerv = open(file_validate, 'r')#Validate file handler.
282 +        handlern = open(file_new, 'r')#New file handler.
283          
284 +        #Variables.
285 +        indexv = indexn = 0
286 +        xv = xn = 0.0
287 +        yv = yn = 0.0
288 +        zv = zn = 0.0
289 +        
290 +        #Read first line.
291 +        linev = handlerv.readline()
292 +        linen = handlern.readline()
293 +        
294 +        while linev:
295 +                if '<StuntDoubles>' in linev:
296 +                        linev = handlerv.readline()
297 +                        linen = handlern.readline()
298 +                        while 2:
299 +                                Lv = linev.split()
300 +                                Ln = linen.split()
301 +                                
302 +                                #If any of these fail, then the files do not match line by line.
303 +                                try:
304 +                                        indexv = int(Lv[0])
305 +                                        indexn = int(Ln[0])
306 +                                        xv = float(Lv[2])
307 +                                        yv = float(Lv[3])
308 +                                        zv = float(Lv[4])
309 +                                        xn = float(Ln[2])
310 +                                        yn = float(Ln[3])
311 +                                        zn = float(Ln[4])
312 +                                except:
313 +                                        logger.warning("Format: files do not follow the same format \n '%s' \n '%s'", linev.strip(), linen.strip())
314 +                                        return True
315 +                                
316 +                                if indexv != indexn:
317 +                                        logger.warning("Indexes do not match: %d | %d", indexv, indexn)
318 +                                        
319 +                                fediff = absDiff(xv, xn, ignore_sign)
320 +                                if fediff > epsilon:
321 +                                        logger.warning("Line: position x on index %d do not match", indexv)
322 +                                        return True
323 +                                
324 +                                fediff = absDiff(yv, yn, ignore_sign)
325 +                                if fediff > epsilon:
326 +                                        logger.warning("Line: position y on index %d do not match", indexv)
327 +                                        return True
328 +                                
329 +                                fediff = absDiff(zv, zn, ignore_sign)
330 +                                if fediff > epsilon:
331 +                                        logger.warning("Line: position z on index %d do not match", indexv)
332 +                                        return True
333 +                                
334 +                                linev = handlerv.readline()
335 +                                linen = handlern.readline()
336 +                                
337 +                                if '</StuntDoubles>' in linev:
338 +                                        break
339 +                elif '<FrameData>' in linev:
340 +        
341 +                        linev = handlerv.readline()
342 +                        linen = handlern.readline()
343 +                        
344 +                        while 1:
345 +                                if 'Time' in linev:
346 +                                        Ltv = linev.split(':')
347 +                                        Ltn = linen.split(':')
348 +                                        
349 +                                        if int(Ltv[1]) != int(Ltn[1]):
350 +                                                logger.warning("Time: FrameData time does not match.")
351 +                                                return True
352 +                                elif '</FrameData>' in linev:
353 +                                        break
354 +                                linev = handlerv.readline()
355 +                                linen = handlern.readline()
356 +                        
357 +                linev = handlerv.readline()
358 +                linen = handlern.readline()
359 +        return False
360 +        

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines