Esempio n. 1
0
def hex_rst():
    filename = os.path.join(testfiles_path, 'hex_201.rst')
    return pyansys.read_binary(filename)
Esempio n. 2
0
def test_loadbeam():
    linkresult_path = os.path.join(testfiles_path, 'link1.rst')
    linkresult = pyansys.read_binary(linkresult_path)
    assert np.any(linkresult.grid.cells)
Esempio n. 3
0
def result():
    test_path = os.path.dirname(os.path.abspath(__file__))
    testfiles_path = os.path.join(test_path, 'testfiles')
    testfile = os.path.join(testfiles_path,
                            'time_hist-nsl_acc_vel-component.rst')
    return pyansys.read_binary(testfile)
    #compute the file name:node,force
    fname, ext = os.path.splitext(file)

    ipTable = fname.split('_')

    #x=float(ipTable[1])
    #y=float(ipTable[2])
    #z=float(ipTable[3])

    print(fname)
    #print(x)
    #print(y)
    #print(z)

    #open rst file
    result = pyansys.read_binary(os.path.join(path, file))
    print(result)

    nsnum, nodal_stress = result.nodal_stress(0)

    #ndnum, nodal_dof=result.nodal_solution(0)

    # Number of Nodes
    #N = nsnum.shape[0]
    #print("There are "+str(N)+" Nodes.")
    N = 567

    #nodes pos
    geometry = result.geometry
    nodespos = geometry['nodes']
    #print(nodespos)
Esempio n. 5
0
def emat():
    emat_bin = pyansys.read_binary(emat_filename)
    assert isinstance(emat_bin, EmatFile)
    return emat_bin
Esempio n. 6
0
def test_file_not_supported():
    with pytest.raises(RuntimeError):
        pyansys.read_binary(os.path.join(testfiles_path, 'file.esav'))
Esempio n. 7
0
def thermal_rst():
    filename = os.path.join(testfiles_path, 'file.rth')
    return pyansys.read_binary(filename)
Esempio n. 8
0
def run_with_input(x,y,z):
    V = 0.1125*(0.3*0.1-0.16*0.04)
    gravity=  (9.8 * 487 * V)/N_ 

    input_x = [test_x[0][:]]
    #input_y_stress = test_y_stress[0][:]
    #input_y_displacement = test_y_displacement[0][:]
    
    x_ = -x/1.41421 + y/1.41421
    y_ = z - x/1.41421 - y/1.41421
    s_ = (x_**2+y_**2)**0.5
    x_ = x_*200/s_
    y_ = y_*200/s_

    for n in range(0,N_):
        if input_x[0][n][4]!=0 and input_x[0][n][5]!=0:
            input_x[0][n][4] = x
            input_x[0][n][5] = y
            input_x[0][n][6] = z + gravity
    
    
    saver = tf.train.Saver()
    #saver.restore(sess, "/summer_research/chair/ckpt/Network_CNN_v2.4.2_chair_str_model.ckpt") # stress
    #predict_stress = fc_layer_2_stress.eval(session=sess,feed_dict = {inputPC: input_x, inputGraph: new_A, keep_prob_1: 1, keep_prob_2: 1})
    

    saver.restore(sess, "/summer_research/chair/ckpt/Network_CNN_v2.4.2_chair_dis_temp_model.ckpt") # displacement
    predict_displacement = fc_layer_2_displacement.eval(session=sess,feed_dict = {inputPC: input_x,
        inputGraph: batch_A, 
        #outputLabel_displacement: input_y_displacement,
        keep_prob_1: 1, keep_prob_2: 1})
    #evaluate()
    predict_displacement = [[_i[0]/1e11]+[_i[1]/1e11]+[_i[2]/1e11] for _i in predict_displacement[0]]
    
    result = pyansys.read_binary("RST.rst")
    '''
    a = np.array(predict_stress)
    scalars = a[:, :3]
    scalars = (scalars*scalars).sum(1)**0.5
    B = np.zeros((557,3))
    for i in range(165):
        B[i][0]=scalars[i]

    #mi = min(scalars)
    ma = max(scalars)
    plot_range = [round(500,-2),round(ma*0.25,-3)]

    #print(predict_stress)
    #print(predict_displacement)
    #rst_path = '1_-22.228909891907985_-57.001098696703046_84.36130192338905.rst'
    
    
    label_pngpath = 'D:\\summer_research\\png\\stress\\original_stress'+str(x)+'_'+str(y)+'_'+str(z)+'.png'
    #result.plot_nodal_solution(rnum = 0,screenshot=pngpath,interactive=False)
    result.plot_principal_nodal_stress(rnum=0,stype='INT',screenshot=label_pngpath,interactive=False,rng=plot_range)

    
    predict_pngpath = 'D:\\summer_research\\png\\stress\\prediction_stress'+str(x)+'_'+str(y)+'_'+str(z)+'.png'
    result._plot_point_scalars(B.transpose(),screenshot=predict_pngpath,interactive=False,stitle='Label Stress',rng=plot_range)

    TINT_COLOR = (0, 0, 0)
    image = Image.open(predict_pngpath)
    image = image.convert("RGBA")
    tmp = Image.new('RGBA', image.size, TINT_COLOR+(0,))
    
    
    draw = ImageDraw.Draw(tmp)

    draw.line([(518,388),(518+x_,388+y_)],fill=TINT_COLOR+(127,),width=5)
    draw.polygon([(518+x_*1.1,388+y_*1.1),(518+x_+y_*0.1,388+y_-x_*0.1),(518+x_-y_*0.1,388+y_+x_*0.1)],fill=TINT_COLOR+(127,))
    draw.polygon(((850,390),(830,497),(393,250),(383,158)), fill=TINT_COLOR+(127,))#topleft bottom left bottom right top right
    image = Image.alpha_composite(image, tmp)
    image = image.convert("RGB")
    circle='D:\\summer_research\\png\\stress\\prediction_circle_stress'+str(x)+'_'+str(y)+'_'+str(z)+'.png'
    image.save(circle)

    predict_png = Image.open(predict_pngpath)
    label_png = Image.open(label_pngpath)
    combined_png=Image.new('RGB', (1024*2,745))
    combined_png.paste(predict_png,(0,0))
    combined_png.paste(label_png,(1024,0))
    filename='D:\\summer_research\\png\\stress\\combine_stress'+str(x)+'_'+str(y)+'_'+str(z)+'.png'
    combined_png.save(filename)
    '''

    ####################
    ####################
    
    a = np.array(predict_displacement)
    #print(a)
    #print(len(a))
    #print(len(a[0]))
    scalars = a[ :, :3]
    scalars = (scalars*scalars).sum(1)**0.5
    B = np.zeros((N_,3))
    for i in range(N_):
        B[i][0]=scalars[i]

    plot_range = [round(min(scalars+1e-9),9),round(max(scalars),9)]

    #label_pngpath = 'D:\\summer_research\\chair\\png\\displacement\\original_displacement'+str(x)+'_'+str(y)+'_'+str(z)+'.png'
    #result.plot_nodal_solution(rnum = 0,screenshot=pngpath,interactive=False)
    #result.plot_nodal_solution(rnum=0,screenshot=label_pngpath,interactive=False,rng=plot_range)

    
    predict_pngpath = 'D:\\summer_research\\chair\\png\\displacement_2\\prediction_displacement_'+str(x)+'_'+str(y)+'_'+str(z)+'.png'
    result._plot_point_scalars(B.transpose(),screenshot=predict_pngpath,interactive=False,stitle='Label displacement',rng=plot_range)

    TINT_COLOR = (0, 0, 0)
    image = Image.open(predict_pngpath)
    image = image.convert("RGBA")
    tmp = Image.new('RGBA', image.size, TINT_COLOR+(0,))
    draw = ImageDraw.Draw(tmp)
    draw.line([(502,263),(502+x_,263+y_)],fill=TINT_COLOR+(127,),width=10)
    draw.polygon([(502+x_*1.2,263+y_*1.2),(502+x_+y_*0.2,263+y_-x_*0.2),(502+x_-y_*0.2,263+y_+x_*0.2)],fill=TINT_COLOR+(127,))
    #draw.polygon(((850,390),(830,497),(393,250),(383,158)), fill=TINT_COLOR+(127,))#topleft bottomleft bottomright topright
    image = Image.alpha_composite(image, tmp)
    image = image.convert("RGB")
    circle='D:\\summer_research\\chair\\png\\displacement_2\\prediction_circle_displacements_'+str(x)+'_'+str(y)+'_'+str(z)+'.png'
    image.save(circle)
    '''
Esempio n. 9
0
except:
    testfiles_path = '/home/alex/afrl/python/source/pyansys/tests/testfiles'


ANSYS_ELEM = [[0.17662E-07, 79.410, -11.979, -0.11843E-02, 4.8423, -0.72216E-04],
              [0.20287E-07, 91.212, 27.364, -0.13603E-02, 4.8423, -0.72216E-04],
              [0.20287E-07, 91.212, 27.364, -0.13603E-02, -4.8423, 0.72216E-04],
              [0.17662E-07, 79.410, -11.979, -0.11843E-02, -4.8423, 0.72216E-04]]

ANSYS_NODE = [[0.20287E-07, 91.212, 27.364, -0.13603E-02, 4.8423, -0.72216E-04],
              [0.17662E-07, 79.410, -11.979, -0.11843E-02, 4.8423, -0.72216E-04],
              [0.17662E-07, 79.410, -11.979, -0.11843E-02, -4.8423, 0.72216E-04],
              [0.20287E-07, 91.212, 27.364, -0.13603E-02, -4.8423, 0.72216E-04]]

result_file = os.path.join(testfiles_path, 'shell281.rst')
test_result = pyansys.read_binary(result_file, valid_element_types=['281'])

# estress, elem, enode = test_result.element_stress(0, in_element_coord_sys=False)
estress, elem, enode = test_result.element_stress(0, in_element_coord_sys=True)
print(estress[23][:4])

# debug
np.any(np.isclose(-50.863, estress[23]))
np.isclose(-50.863, estress[23]).any(1).nonzero()
# np.isclose(-50.863, table).any(1).nonzero()


f.seek(400284 - 8)
table = read_table(f, 'f')
# f.seek(400284)
ncomp = 6
Esempio n. 10
0
def test_fullreader():
    fobj = pyansys.read_binary(fullfile)
    dofref, k, m = fobj.load_km()
    assert dofref.size
    assert k.size
    assert m.size
Esempio n. 11
0
if __name__ == "__main__":
    import sys
    import pyansys

    file_name = sys.argv[1]
    print('FILE NAME: ' + file_name)
    res = pyansys.read_binary(file_name)
    res.plot_nodal_solution(0, 'x', label='Displacement')
Esempio n. 12
0
def test_plot_nodal_temperature():
    temp_rst = pyansys.read_binary(temperature_rst)
    temp_rst.plot_nodal_temperature(0, off_screen=True)
Esempio n. 13
0
    pontoon = pyansys.download_pontoon()
except:
    pontoon = None

try:
    __file__
except:  # for testing
    __file__ = '/home/alex/afrl/python/source/pyansys/tests/test_rst.py'

test_path = os.path.dirname(os.path.abspath(__file__))
testfiles_path = os.path.join(test_path, 'testfiles')

is16_filename = os.path.join(testfiles_path, 'is16.rst')
is16_known_result = os.path.join(testfiles_path, 'is16.npz')
if os.path.isfile(is16_filename):
    is16 = pyansys.read_binary(is16_filename)
else:
    is16 = None

temperature_rst = os.path.join(testfiles_path, 'temp_v13.rst')
temperature_known_result = os.path.join(testfiles_path, 'temp_v13.npz')


@pytest.mark.skipif(vm33 is None, reason="Requires example files")
def test_write_tables(tmpdir):
    filename = str(tmpdir.mkdir("tmpdir").join('vm33.txt'))
    vm33.write_tables(filename)
    assert os.path.isfile(filename)


def test_read_volume():
Esempio n. 14
0
def volume_rst():
    rst_file = os.path.join(testfiles_path, 'vol_test.rst')
    return pyansys.read_binary(rst_file)
Esempio n. 15
0
def test_reaction_forces():
    rst = pyansys.read_binary(os.path.join(testfiles_path, 'vm1.rst'))
    nnum, forces = rst.nodal_static_forces(0)
    assert np.allclose(nnum, [1, 2, 3, 4])
    assert np.allclose(forces[:, 1], [-600, 250, 500, -900])
Esempio n. 16
0
def result():
    filename = os.path.join(testfiles_path, 'pyansys_182_183_42_82.rst')
    return pyansys.read_binary(filename)
Esempio n. 17
0
def test_file_not_found():
    with pytest.raises(FileNotFoundError):
        pyansys.read_binary('not_a_file.rst')
Esempio n. 18
0
def _download_and_read(filename):
    saved_file, _ = _download_file(filename)
    return pyansys.read_binary(saved_file)
Esempio n. 19
0
def static_canteliver_bc():
    filename = os.path.join(testfiles_path, 'rst', 'beam_static_bc.rst')
    return pyansys.read_binary(filename)
Esempio n. 20
0
def result_x():
    filename = os.path.join(testfiles_path, 'cyc12.rst')
    return pyansys.read_binary(filename)
import pyansys
import os
from PIL import ImageGrab

path = 'D:\\summer_research\\rst_data\\rst'
savepath = 'D:\\summer_research\\rst_data\\plot'

#cpos = [(5.583824390900331, 4.98382439090033, 6.333824390900331), (1.0, 0.4, 1.75), (0.0, 0.0, 1.0)]
#cpos = [(5.583824390900331, 4.98382439090033, 6.333824390900331), (1.0, 0.4, 1.75), (0.0, 0.0, 1.0)]
i = 0
for file in os.listdir(path):
    i = i + 1
    fullname = os.path.join(path, file)
    fname, ext = os.path.splitext(file)

    result = pyansys.read_binary(fullname)

    ipTable = fname.split('_')
    #print(ipTable)
    x = ipTable[1]
    y = ipTable[2]
    z = ipTable[3]

    #if (i==1):
    #cpos = result.plot_nodal_solution(0)
    #print(cpos)

    #cpos=cpos
    #screenshot=screen_file
    if (float(x) > 0):
        x = '00' + x
Esempio n. 22
0
def cyclic_v182_z():
    # static result z axis
    filename = os.path.join(cyclic_testfiles_path, 'cyclic_v182.rst')
    return pyansys.read_binary(filename)
Esempio n. 23
0
# import pytest
import numpy as np
import os
import pyansys
from pyansys import examples

try:
    __file__
except NameError:
    __file__ = '/home/alex/afrl/python/source/pyansys/tests/test_solid186.py'

test_path = os.path.dirname(os.path.abspath(__file__))
testfiles_path = os.path.join(test_path, 'testfiles', 'solid186')

result = pyansys.read_binary(examples.rstfile)
archive = pyansys.Archive(examples.hexarchivefile)


def test_geometry_elements():
    r_elem = result.geometry['elem'][result.sidx_elem]
    a_elem = archive.raw['elem']
    assert np.allclose(r_elem, a_elem)


def test_geometry_nodes():
    r_node = result.geometry['nodes']
    a_node = archive.raw['nodes']
    assert np.allclose(r_node, a_node)


def test_geometry_nodenum():
Esempio n. 24
0
def cyclic_v182_z_with_comp():
    # cyclic modal with component
    filename = os.path.join(cyclic_testfiles_path, 'cyclic_v182_w_comp.rst')
    return pyansys.read_binary(filename)
Esempio n. 25
0
def test_file_close(tmpdir):
    tmpfile = str(tmpdir.mkdir("tmpdir").join('tmp.vtk'))
    shutil.copy(examples.rstfile, tmpfile)
    rst = pyansys.read_binary(tmpfile)
    nnum, stress = rst.nodal_stress(0)
    os.remove(tmpfile)
Esempio n. 26
0
 def result(self):
     """ Returns a binary interface to the result file """
     resultfile = os.path.join(self.path, '%s.rst' % self.jobname)
     if not os.path.isfile(resultfile):
         raise Exception('No results found at %s' % resultfile)
     return pyansys.read_binary(resultfile)
Esempio n. 27
0
def result():
    return pyansys.read_binary(examples.rstfile)
Esempio n. 28
0
import os
import numpy as np

import pyansys
import pytest

TEST_PATH = os.path.dirname(os.path.abspath(__file__))
TESTFILES_PATH = os.path.join(TEST_PATH, 'testfiles')
TESTFILE = os.path.join(TESTFILES_PATH, 'time_hist-nsl_acc_vel-component.rst')
RESULT = pyansys.read_binary(TESTFILE)


@pytest.mark.parametrize("time_hist_key", ['NSL', 'VEL', 'ACC'])
def test_time_history(time_hist_key):
    nnum, values = RESULT.nodal_time_history(time_hist_key)
    assert np.allclose(nnum, RESULT.nnum)
    assert values.ndim == 3
    assert values.shape[1] == nnum.size
Esempio n. 29
0
def result():
    test_path = os.path.dirname(os.path.abspath(__file__))
    return pyansys.read_binary(os.path.join(test_path, 'shell181.rst'))
Esempio n. 30
0
def hex_pipe_corner():
    filename = os.path.join(testfiles_path, 'rst', 'cyc_stress.rst')
    return pyansys.read_binary(filename)