예제 #1
0
파일: Read.py 프로젝트: bebopsan/peyeQM
def ReadVRML(archivo):
    #Open the file
    f=open(archivo,'r')
    stop=0
    while stop==0:
        line=f.readline()
        if 'point [' in line:
            stop=1
    
    n=np.zeros(3)
    n=numscan(f)
    points=n
    while stop==1:
        
        back=f.tell()
        line=f.readline()
        f.seek(back)
        n=numscan(f)
        
        if n!=[]:
            points=np.vstack((points,n))  
        if ']'in line:
            stop=0
                      
    while stop==0:
        line=f.readline()
        if 'coordIndex' in line:
            stop=1
    n=numscan(f)
    triangles=n[0:3]
    while stop==1:
        back=f.tell()
        line=f.readline()
        f.seek(back)
        n=numscan(f)
        if n!=[]:
            triangles=np.vstack((triangles,n[0:3]))  
        if ']'in line:
            stop=0

    return points,triangles
예제 #2
0
파일: ReadMesh.py 프로젝트: bebopsan/peyeQM
def ReadSolverInput(filename):
    """
        Reads the solver input from a file of gmsh ASCII format V2.2.
        This input is to be read by the Solver module.
        Parameters:
        -----------
            filename: String which contain filename and path of the output file.
        Returns:
	--------
            SolverInput: List with the following parameters:

            [Dimension,BCType,parameter,Eq,Type,AnalisisParam]

            Dimension:  int parameter that tells the program wether to solve for a
                    1D problem or a 2D problem (not supported yet)

            BCType:     String parameter for the selection of a border condition
                        that can be either:

                            'Dir'   For the Dirichlet border condition
                                    (Infinite potential well).

                            'Bloch' For the periodic formulation of the problem.
                                    (Electron in a periodic material )
                    
            parameter:  Is an array that describes the potential actuating over the
                        the elements of the domain given by Elems. For each element in
                        Elems there is an associated potential value on the same
                        position in the array parameter.

                        The potential in Scroedinger equation defines the specific
                        nature of the problem to be solved. For more details on how
                        to define a potential and what does it mean pleas read the
                        documentation of the Potential1D function in the module PrePro.

           
            Eq:         Can be 'Schroedinger' or another not implemented yet
            

            Type:       String that tells wether to solve the stationary version of
                        the equation or another not yet suported.

                        'Stationary'   

            AnalisisParam:   Array that contains the information regarding the number
                             of solutions to be computed and wether to save the values
                             or not.

                            AnalisisParam[0]:  String  answer to the question
                                                       save  Eigen Values?
                            AnalisisParam[1]:  String  answer to the question
                                                       save  Eigen Vectors?
                            AnalisisParam[2]:  Integer  number of Eigen Values to save
                            AnalisisParam[3]:  Integer  number of Eigen Vectors to save          
            
         Last modification: date 25/10/2011
    """
    f=open(filename,'r')
    line=f.readline()
    while '$Solver' not in line:
            line=f.readline()
            if '$Solver' in line:
                
                Dimension=int(f.readline())
                BCType=f.readline()
                here=f.tell()
                if f.readline ==[]:
                    params=[]
                else:
                    f.seek(here)
                    parameter=np.array(numscan(f))
                    while True:
                        here=f.tell()
                        b=numscan(f)
                        if b==[]:
                            break
                        parameter=np.vstack((parameter,b))
                f.seek(here)
                Eq=f.readline()
                Type=f.readline()
                AnalisisParam=f.readline()
                AnalisisParam=AnalisisParam.strip('[ ]\n')
                AnalisisParam=AnalisisParam.split(',')
                SolverInput=[Dimension,BCType,parameter,Eq,Type,AnalisisParam]
                return SolverInput
                break
            if line=='':
                SolverInput=[]
                print 'Found no input for solver module' 
                return SolverInput
                break
예제 #3
0
def read_solver_input(filename):
    """
    Reads the solver input from a file of gmsh ASCII format V2.2.
    This input is to be read by the Solver module.
    Parameters:
    -----------
    filename: String which contain filename and path of the output file.
    Returns:
    --------
    solver_input: List with the following parameters:

    [dimension,bc_type,parameter,eq,sol_type,analysis_param]

    dimension:  int parameter that tells the program wether to solve for a
            1D problem or a 2D problem (not supported yet)

    bc_type:     String parameter for the selection of a border condition
                that can be either:

                    'Dir'   For the Dirichlet border condition
                            (Infinite potential well).

                    'Bloch' For the periodic formulation of the problem.
                            (Electron in a periodic material )
            
    parameter:  Is an array that describes the potential actuating over the
                the elements of the domain given by Elems. For each element in
                Elems there is an associated potential value on the same
                position in the array parameter.

                The potential in Scroedinger equation defines the specific
                nature of the problem to be solved. For more details on how
                to define a potential and what does it mean pleas read the
                documentation of the Potential1D function in the module PrePro.

   
    eq:         Can be 'Schroedinger' or another not implemented yet
    

    sol_type:       String that tells wether to solve the stationary version of
                the equation or another not yet suported.

                'Stationary'   

    analysis_param:   Array that contains the information regarding the number
                     of solutions to be computed and wether to save the values
                     or not.

                    analysis_param[0]:  String  answer to the question
                                               save  Eigen Values?
                    analysis_param[1]:  String  answer to the question
                                               save  Eigen Vectors?
                    analysis_param[2]:  Integer  number of Eigen Values to save
                    analysis_param[3]:  Integer  number of Eigen Vectors to save 
                    analysis_param[4]:  Integer number of wave numbers 
                                        in x to sweep
                    analysis_param[5]:  Integer number of wave numbers 
                                        in y to sweep
                    analysis_param[6]:  biggest value of k. it may be the lenght
                                        of the dommain                                        
                    
    bc_filename:    string that tells where to look for the boundary 
                    conditions  
                        
     Last modification: date 14/11/2011
    """
    f = open(filename,'r')
    line = f.readline()
    while '$Solver' not in line:
            line = f.readline()
            if '$Solver' in line:
                
                dimension = int(f.readline())
                bc_type = f.readline().strip('\n')
                here = f.tell()
                if f.readline == []:
                    parameter = []
                else:
                    f.seek(here)
                    parameter = np.array(numscan(f))
                    while True:
                        here = f.tell()
                        b = numscan(f)
                        if b == []:
                            break
                        parameter = np.vstack((parameter, b))
                f.seek(here)
                eq = f.readline().strip('\n')
                sol_type = f.readline().strip('\n')
                analysis_param = f.readline()
                analysis_param = analysis_param.strip('[ ]\n')
                analysis_param = analysis_param.split(',')
                bc_filename = f.readline().strip('\n')
                solver_input = [dimension, bc_type, parameter, eq, sol_type,  \
                                analysis_param, bc_filename]
                return solver_input
                break
            if line == '':
                solver_input = []
                print 'Found no input for solver module' 
                return solver_input
                break