Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #409 from simphony/update-metadata-502d4c71847f95a…
Browse files Browse the repository at this point in the history
…202ccf1a29902e16f2f4d55a8

Updated against 502d4c71847f95a202ccf1a29902e16f2f4d55a8
  • Loading branch information
stefanoborini committed Apr 6, 2017
2 parents 2b21e58 + 0526fde commit fe09a65
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 46 deletions.
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ exclude = doc/*
# Addition of CFD metadata: 1b64cc80045cf99ffa3594342b44098c1c09be8d
# Addition of PDE conditions: 19daa41858438d93c79c4957c56b7c78693083a8
# Addition of PR #129, #130, #132: 5628c9e6e24f9b7ce0bddc9ec7d6dc07b41ec265
repotag = 5628c9e6e24f9b7ce0bddc9ec7d6dc07b41ec265
# Addition of inlet-outlet PR #134: 502d4c71847f95a202ccf1a29902e16f2f4d55a8
repotag = 502d4c71847f95a202ccf1a29902e16f2f4d55a8
4 changes: 3 additions & 1 deletion simphony/core/cuba.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class CUBA(Enum):
INCOMPRESSIBLE_FLUID_MODEL = "INCOMPRESSIBLE_FLUID_MODEL"
INDEX = "INDEX"
INITIAL_VISCOSITY = "INITIAL_VISCOSITY"
INLET_OUTLET = "INLET_OUTLET"
INLET_OUTLET_VELOCITY = "INLET_OUTLET_VELOCITY"
INLET_OUTLET_VOLUME_FRACTION = "INLET_OUTLET_VOLUME_FRACTION"
INTEGRATION_STEP = "INTEGRATION_STEP"
INTEGRATION_TIME = "INTEGRATION_TIME"
INTERATOMIC_POTENTIAL = "INTERATOMIC_POTENTIAL"
Expand Down Expand Up @@ -141,6 +142,7 @@ class CUBA(Enum):
MESOSCOPIC_STRESS_MODEL = "MESOSCOPIC_STRESS_MODEL"
MINIMUM_VISCOSITY = "MINIMUM_VISCOSITY"
MINOR = "MINOR"
MIXED_CONDITION = "MIXED_CONDITION"
MIXTURE_MODEL = "MIXTURE_MODEL"
MODEL_EQUATION = "MODEL_EQUATION"
MOLECULAR_DYNAMICS = "MOLECULAR_DYNAMICS"
Expand Down
20 changes: 17 additions & 3 deletions simphony/core/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,10 +1248,17 @@
shape=[1],
length=None,
dtype=None),
'INLET_OUTLET': Keyword(
name='InletOutlet',
'INLET_OUTLET_VELOCITY': Keyword(
name='InletOutletVelocity',
definition='Inlet outlet boundary condition (outlet condition is zero gradient and inlet given variable value)', # noqa
key='INLET_OUTLET',
key='INLET_OUTLET_VELOCITY',
shape=[1],
length=None,
dtype=None),
'INLET_OUTLET_VOLUME_FRACTION': Keyword(
name='InletOutletVolumeFraction',
definition='Inlet outlet boundary condition (outlet condition is zero gradient and inlet given variable value)', # noqa
key='INLET_OUTLET_VOLUME_FRACTION',
shape=[1],
length=None,
dtype=None),
Expand Down Expand Up @@ -1360,6 +1367,13 @@
shape=[1],
length=None,
dtype=None),
'MIXED_CONDITION': Keyword(
name='MixedCondition',
definition='general mixed boundary condition', # noqa
key='MIXED_CONDITION',
shape=[1],
length=None,
dtype=None),
'MIXTURE_MODEL': Keyword(
name='MixtureModel',
definition='Mixture (drift flux) model', # noqa
Expand Down
4 changes: 3 additions & 1 deletion simphony/cuds/meta/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
from .herschel_bulkley_model import HerschelBulkleyModel # noqa
from .hexagonal_lattice import HexagonalLattice # noqa
from .incompressible_fluid_model import IncompressibleFluidModel # noqa
from .inlet_outlet import InletOutlet # noqa
from .inlet_outlet_velocity import InletOutletVelocity # noqa
from .inlet_outlet_volume_fraction import InletOutletVolumeFraction # noqa
from .integration_step import IntegrationStep # noqa
from .integration_time import IntegrationTime # noqa
from .interatomic_potential import InteratomicPotential # noqa
Expand All @@ -70,6 +71,7 @@
from .mesoscopic import Mesoscopic # noqa
from .mesoscopic_relative_velocity_model import MesoscopicRelativeVelocityModel # noqa
from .mesoscopic_stress_model import MesoscopicStressModel # noqa
from .mixed_condition import MixedCondition # noqa
from .mixture_model import MixtureModel # noqa
from .model_equation import ModelEquation # noqa
from .molecular_dynamics import MolecularDynamics # noqa
Expand Down
36 changes: 0 additions & 36 deletions simphony/cuds/meta/inlet_outlet.py

This file was deleted.

75 changes: 75 additions & 0 deletions simphony/cuds/meta/inlet_outlet_velocity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from simphony.core import Default # noqa
from .mixed_condition import MixedCondition
from simphony.core.cuba import CUBA
from simphony.cuds import meta_validation


class InletOutletVelocity(MixedCondition):
"""
Inlet outlet boundary condition (outlet condition is zero
gradient and inlet given variable value)
"""
cuba_key = CUBA.INLET_OUTLET_VELOCITY

def __init__(self, velocity, material, description=Default, name=Default):
super(InletOutletVelocity, self).__init__(
material=material, description=description, name=name)
self._init_models()
self._init_variables()
self._init_velocity(velocity)

@classmethod
def supported_parameters(cls):
try:
base_params = super(InletOutletVelocity,
cls).supported_parameters()
except AttributeError:
base_params = ()
return tuple(set((CUBA.VELOCITY, ) + base_params))

def _init_models(self):
self._models = self._default_models() # noqa

@property
def models(self):
return self._models

def _default_models(self):
return ['CUBA.CONTINUUM'] # noqa

def _default_definition(self):
return "Inlet outlet boundary condition (outlet condition is zero gradient and inlet given variable value)" # noqa

def _init_variables(self):
self._variables = self._default_variables() # noqa

@property
def variables(self):
return self._variables

def _default_variables(self):
return ['CUBA.VELOCITY'] # noqa

def _init_velocity(self, value):
if value is Default:
value = self._default_velocity()

self.velocity = value

@property
def velocity(self):
return self.data[CUBA.VELOCITY]

@velocity.setter
def velocity(self, value):
value = self._validate_velocity(value)
self.data[CUBA.VELOCITY] = value

def _validate_velocity(self, value):
value = meta_validation.cast_data_type(value, 'VELOCITY')
meta_validation.check_valid_shape(value, [1], 'VELOCITY')
meta_validation.validate_cuba_keyword(value, 'VELOCITY')
return value

def _default_velocity(self):
raise TypeError("No default for velocity")
79 changes: 79 additions & 0 deletions simphony/cuds/meta/inlet_outlet_volume_fraction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from simphony.core import Default # noqa
from .mixed_condition import MixedCondition
from simphony.core.cuba import CUBA
from simphony.cuds import meta_validation


class InletOutletVolumeFraction(MixedCondition):
"""
Inlet outlet boundary condition (outlet condition is zero
gradient and inlet given variable value)
"""
cuba_key = CUBA.INLET_OUTLET_VOLUME_FRACTION

def __init__(self,
volume_fraction,
material,
description=Default,
name=Default):
super(InletOutletVolumeFraction, self).__init__(
material=material, description=description, name=name)
self._init_models()
self._init_variables()
self._init_volume_fraction(volume_fraction)

@classmethod
def supported_parameters(cls):
try:
base_params = super(InletOutletVolumeFraction,
cls).supported_parameters()
except AttributeError:
base_params = ()
return tuple(set((CUBA.VOLUME_FRACTION, ) + base_params))

def _init_models(self):
self._models = self._default_models() # noqa

@property
def models(self):
return self._models

def _default_models(self):
return ['CUBA.CONTINUUM'] # noqa

def _default_definition(self):
return "Inlet outlet boundary condition (outlet condition is zero gradient and inlet given variable value)" # noqa

def _init_variables(self):
self._variables = self._default_variables() # noqa

@property
def variables(self):
return self._variables

def _default_variables(self):
return ['CUBA.VOLUME_FRACTION'] # noqa

def _init_volume_fraction(self, value):
if value is Default:
value = self._default_volume_fraction()

self.volume_fraction = value

@property
def volume_fraction(self):
return self.data[CUBA.VOLUME_FRACTION]

@volume_fraction.setter
def volume_fraction(self, value):
value = self._validate_volume_fraction(value)
self.data[CUBA.VOLUME_FRACTION] = value

def _validate_volume_fraction(self, value):
value = meta_validation.cast_data_type(value, 'VOLUME_FRACTION')
meta_validation.check_valid_shape(value, [1], 'VOLUME_FRACTION')
meta_validation.validate_cuba_keyword(value, 'VOLUME_FRACTION')
return value

def _default_volume_fraction(self):
raise TypeError("No default for volume_fraction")
51 changes: 51 additions & 0 deletions simphony/cuds/meta/mixed_condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from simphony.core import Default # noqa
from .condition import Condition
from simphony.core.cuba import CUBA
from simphony.cuds import meta_validation


class MixedCondition(Condition):
"""
general mixed boundary condition
"""
cuba_key = CUBA.MIXED_CONDITION

def __init__(self, material, description=Default, name=Default):
super(MixedCondition, self).__init__(
description=description, name=name)
self._init_material(material)

@classmethod
def supported_parameters(cls):
try:
base_params = super(MixedCondition, cls).supported_parameters()
except AttributeError:
base_params = ()
return tuple(set((CUBA.MATERIAL, ) + base_params))

def _default_definition(self):
return "general mixed boundary condition" # noqa

def _init_material(self, value):
if value is Default:
value = self._default_material()

self.material = value

@property
def material(self):
return self.data[CUBA.MATERIAL]

@material.setter
def material(self, value):
value = self._validate_material(value)
self.data[CUBA.MATERIAL] = value

def _validate_material(self, value):
value = meta_validation.cast_data_type(value, 'MATERIAL')
meta_validation.check_valid_shape(value, [1], 'MATERIAL')
meta_validation.validate_cuba_keyword(value, 'MATERIAL')
return value

def _default_material(self):
raise TypeError("No default for material")
14 changes: 10 additions & 4 deletions simphony/cuds/meta/robin.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
from simphony.core import Default # noqa
from .condition import Condition
from .mixed_condition import MixedCondition
from simphony.core.cuba import CUBA
from simphony.cuds import meta_validation


class Robin(Condition):
class Robin(MixedCondition):
"""
A mixed boundary condition $\alpha \Phi (x) + \beta (x)
\partial {\Phi} / \partial {\bf{n}} (x) = h(x)$, with $h$ is
the value.
"""
cuba_key = CUBA.ROBIN

def __init__(self, dirichlet, neumann, description=Default, name=Default):
super(Robin, self).__init__(description=description, name=name)
def __init__(self,
dirichlet,
neumann,
material,
description=Default,
name=Default):
super(Robin, self).__init__(
material=material, description=description, name=name)
self._init_dirichlet(dirichlet)
self._init_neumann(neumann)

Expand Down

0 comments on commit fe09a65

Please sign in to comment.