Ejemplo n.º 1
0
def run_post(inp,outdir,descr):
    wd = path.join(outdir,path.splitext(path.basename(inp))[0])
    if descr!="": wd+='-'+descr
    print '\n'
    print '--------------------------------------------------------------------------------'
    print '-- RUNNING POSTPROCESSOR:',path.join(wd,'job.odb')
    print '--------------------------------------------------------------------------------'
    # Run the extraction.
    rootdir = os.getcwd()
    try:
        os.chdir(wd)
    except Exception:
        utility.print_error(sys.exc_info()[0],False)
        return 0
    tstart = time.time()
    script = utility.find_file('python/abq_extract_data.py')
    cmd=[ABAQUS,'cae','noGUI='+script,'--','job.odb','data.rpt']
    try:
        utility.run_cmd_screen(cmd)
        with open('data.tmp','w') as of, open('data.rpt','r') as f:
            for line in f:
                line = line.rstrip()    # Remove newline/carriage-return.
                if line.find('NoValue') < 0: of.write(line+'\n')
        shutil.move('data.tmp','data.rpt')
    except Exception:
        utility.print_error(sys.exc_info()[0],False)
        print 'TIME ELAPSED: ',utility.time_elapsed(tstart)
        os.chdir(rootdir)
        return 0
    try:
        import create_result_plots, numpy
        from matplotlib import pyplot
        pyplot.rc('mathtext',default='regular') # Don't use italics for mathmode.
        fig,ax = pyplot.subplots()
        create_result_plots.plot_fem_data(ax,'data.rpt')
        lgd = ax.legend(loc='best',frameon=False,framealpha=0)
        pyplot.savefig('plot.png',bbox_extra_artists=(lgd,), bbox_inches='tight')
        pyplot.close()
        if path.exists('data-energy.rpt'):
            fig,ax = pyplot.subplots()
            create_result_plots.plot_fem_energy(ax,'data-energy.rpt')
            lgd = ax.legend(loc='best',frameon=False,framealpha=0)
            pyplot.savefig('plot-energy.png',bbox_extra_artists=(lgd,), bbox_inches='tight')
            pyplot.close()
        if path.exists('data-strain.csv'):
            fig,ax = pyplot.subplots()
            data = numpy.loadtxt('data-strain.csv',delimiter=',')
            ax.plot(data[:,0],data[:,1],'o-',label='Nominal Strain')
            ax.set_xlabel('Time (meaningless units)')
            ax.set_ylabel('Nominal Strain')
            ax.grid()
            pyplot.savefig('plot-strain.png', bbox_inches='tight')
            pyplot.close()
    except Exception:
        utility.print_error('Failed to create result plots.',False)
    print 'TIME ELAPSED: ',utility.time_elapsed(tstart)
    os.chdir(rootdir)
    return 1
Ejemplo n.º 2
0
def run_abq(inp, outdir, np, descr):
    wd = path.join(outdir, path.splitext(path.basename(inp))[0])
    if descr != "": wd += '-' + descr
    print '\n'
    print '--------------------------------------------------------------------------------'
    print '-- RUNNING ABAQUS:', inp, descr, '(' + str(np) + ' processors)'
    print '--             IN:', wd
    print '--------------------------------------------------------------------------------'
    if path.exists(wd): shutil.rmtree(wd)
    if not inp.endswith('.inp'):
        utility.print_error('Input file must be a .inp Abaqus run file.',
                            False)
        return 0
    # Prepare the directories.
    os.makedirs(wd)
    inpNEW = path.join(wd, 'job.inp')
    if not utility.safe_hardlink(inp, inpNEW):
        shutil.rmtree(wd)
        return 0
    create_env(np, wd)
    # Run the simulation.
    rootdir = os.getcwd()
    os.chdir(wd)
    tstart = time.time()
    cmd = [ABAQUS, 'job=job', 'input=job.inp', 'interactive']
    try:
        utility.run_cmd_screen(cmd)
    except Exception:
        utility.print_error(sys.exc_info()[0], False)
        return 0
    finally:
        print 'TIME ELAPSED: ', utility.time_elapsed(tstart)
        os.chdir(rootdir)
    return 1
Ejemplo n.º 3
0
    if len(params) == 0:
        if 'u' in data:
            calc_params(data, args.descr, model, method, args.poisson, 'u',
                        args.points, params, ext, args.xlim, args.ylim,
                        args.ylimerr)
        if 'b' in data:
            calc_params(data, args.descr, model, method, args.poisson, 'b',
                        args.points, params, ext, args.xlim, args.ylim,
                        args.ylimerr)
        if 'p' in data:
            calc_params(data, args.descr, model, method, args.poisson, 'p',
                        args.points, params, ext, args.xlim, args.ylim,
                        args.ylimerr)

    # TODO - Drucker stability check?

    print '--------------------------------------------------------------------'
    print ' Results for', model.pname(), 'fits.'
    print ' Format:', model.params()
    print ' Model Description:', model.descr()
    print '--------------------------------------------------------------------'
    np.set_printoptions(suppress=False)
    for t, p in params.iteritems():
        print '* Parameters for fit to', MU.get_name(t), 'data.'
        print 'LRsquared:', p[-2]
        print 'GRsquared:', p[-1]
        print 'P:', p[:-2]
        print 'D:', model.compressibility(args.poisson, *p[:-2])
        print
    print 'TOTAL TIME ELAPSED: ', U.time_elapsed(tinit)
Ejemplo n.º 4
0
            r, jobfile = run_slurm(inp, cp, args.qtime, args.outdir,
                                   args.nodes, np, args.descr)
            tC += r
            tA += 1
            # Submit the job.
            if args.array < 0:
                # log = utility.run_cmd(['sbatch','--qos=debug',jobfile])
                log = utility.run_cmd(['sbatch', jobfile])
                print log.rstrip(), '--', jobfile
            else:
                jobs.append(jobfile)
        else:
            if args.all or args.run:
                tC += run_abq(inp, args.outdir, np, args.descr)
                tA += 1
            if args.all or args.post:
                tC += run_post(inp, args.outdir, args.descr)
                tA += 1

    # Submit array job if requested.
    if args.array >= 0:
        run_array(args.outdir, jobs, args.array, cp, args.qtime, args.nodes,
                  np, args.descr)

    print '\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
    print 'TASKS ATTEMPTED:    ', tA
    print 'TASKS COMPLETED:    ', tC
    print 'TOTAL TIME ELAPSED: ', utility.time_elapsed(tinit)
    if tA != tC: print '\t!!!!!!!!!! ', tA - tC, 'tasks failed  !!!!!!!!!!'
    print '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'