Exemplo n.º 1
0
def transfer_model(class_name, file_name=[],
                   compiler_options={}, compiler_log_level='warning'):
    """ 
    Compiles and transfers a model to the ModelicaCasADi interface. 
    
    A model class name must be passed, all other arguments have default values. 
    The different scenarios are:
    
    * Only class_name is passed: 
        - Class is assumed to be in MODELICAPATH.
    
    * class_name and file_name is passed:
        - file_name can be a single path as a string or a list of paths 
          (strings). The paths can be file or library paths.
    
    Library directories can be added to MODELICAPATH by listing them in a 
    special compiler option 'extra_lib_dirs', for example:
    
        compiler_options = 
            {'extra_lib_dirs':['c:\MyLibs1','c:\MyLibs2']}
        
    Other options for the compiler should also be listed in the compiler_options 
    dict.
    
        
    Parameters::
    
        class_name -- 
            The name of the model class.
            
        file_name -- 
            A path (string) or paths (list of strings) to model files and/or 
            libraries.
            Default: Empty list.
                        
        compiler_options --
            Options for the compiler.
            Note that MODELICAPATH is set to the standard for this
            installation if not given as an option.
            Default: Empty dict.
            
        compiler_log_level --
            Set the logging for the compiler. Valid options are:
            'warning'/'w', 'error'/'e', 'info'/'i' or 'debug'/'d'. 
            Default: 'warning'

                  
    Returns::
    
        A Model representing the class given by class_name.

"""
    model = modelicacasadi_wrapper.Model() # no wrapper exists for Model yet
    _transfer_model(model, class_name=class_name, file_name=file_name,
                    compiler_options=compiler_options,
                    compiler_log_level=compiler_log_level)
    return model
Exemplo n.º 2
0
 def transfer_model(*args, **kwargs):
     model = modelicacasadi_wrapper.Model() # no wrapper exists for Model yet
     _transfer_model(model, *args, **kwargs)
     return model