Example #1
0
# -*- coding: utf-8 -*-
"""
===============================================================================
GenericNetwork: Abstract class to construct pore networks
===============================================================================

"""
import itertools
import scipy as sp
import scipy.sparse as sprs
import scipy.spatial as sptl
import OpenPNM.Utilities.misc as misc
from OpenPNM.Utilities import topology
from OpenPNM.Base import Core, Controller, Tools, logging
logger = logging.getLogger(__name__)
ctrl = Controller()
topo = topology()


class GenericNetwork(Core):
    r"""
    GenericNetwork - Base class to construct pore networks

    Parameters
    ----------
    name : string
        Unique name for Network object

    """
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
Example #2
0
# -*- coding: utf-8 -*-
"""
===============================================================================
MatFile: Subclass to import Networks from a Matlab '.mat' file
===============================================================================

"""
import scipy as sp
import scipy.io as spio
import os
from OpenPNM.Network import GenericNetwork
import OpenPNM.Geometry
import OpenPNM.Utilities.misc as misc
from OpenPNM.Base import logging
logger = logging.getLogger(__name__)


class MatFile(GenericNetwork):
    r"""
    MatFile - constructs a pore network from a perfectly formatted .mat file (MATLAB)
    Create network from Matlab file. Returns OpenPNM.Network.GenericNetwork()
    object. The extra data of 'type' will trigger internal and boundary pores.

    Parameters
    ----------
    filename : string
        filename = 'standard_cubic_5x5x5.mat' (default)
        Name of mat file
    path : string
        path='' (default)
        the full path to the mat file on your computer
Example #3
0
'''
###############################################################################
ModelsDict:  Abstract Class for Containing Models
###############################################################################
'''
import inspect
import scipy as sp
from collections import OrderedDict
from OpenPNM.Base import logging, Controller
logger = logging.getLogger()

class ModelWrapper(dict):
    r"""
    Accepts a model from the OpenPNM model library, as well as all required 
    and optional argumnents, then wraps it in a custom dictionary with 
    various methods for working with the models.

    """
    def __init__(self,**kwargs):
        self.update(**kwargs)

    def __call__(self):
        return self['model'](**self)
        
    def __str__(self):
        header = '-'*60
        print(header)
        print(self['model'].__module__+'.'+self['model'].__name__)
        print(header)
        print("{a:<20s} {b}".format(a='Argument Name',b='Value / (Default)'))
        print(header)
Example #4
0
"""
###############################################################################
Controller:  Overall controller class
###############################################################################
"""
import pickle as _pickle
import copy as _copy
import time
import random
import string
import OpenPNM
from OpenPNM.Base import logging
logger = logging.getLogger()


class Controller(dict):
    # The following __instance__ class variable and subclassed __new__ method
    # makes the Controller class a 'Singleton'.  This way, any instantiation
    # of a controller object anywhere in the code will return the same object.
    __instance__ = None

    def __new__(cls, *args, **kwargs):
        if Controller.__instance__ is None:
            Controller.__instance__ = dict.__new__(cls)
        return Controller.__instance__

    def __init__(self):
        self.comments = 'Using OpenPNM ' + OpenPNM.__version__

    def __str__(self):
        lines = []