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 #407 from simphony/update-metadata-8c3ab406d73a804…
Browse files Browse the repository at this point in the history
…c35fc47cdb4a514495e0143d3

Update to support metadata PDE conditions (PR simphony-metadata#121/#122)
  • Loading branch information
stefanoborini committed Mar 24, 2017
2 parents 87f6a92 + 63fe3eb commit b7d24bc
Show file tree
Hide file tree
Showing 24 changed files with 795 additions and 382 deletions.
6 changes: 4 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
exclude = doc/*

[build_meta]
# Post 0.6.0. Addition of CFD metadata
repotag=1b64cc80045cf99ffa3594342b44098c1c09be8d
# Post 0.6.0.
# Addition of CFD metadata: 1b64cc80045cf99ffa3594342b44098c1c09be8d
# Addition of PDE conditions: 19daa41858438d93c79c4957c56b7c78693083a8
repotag = 19daa41858438d93c79c4957c56b7c78693083a8
11 changes: 10 additions & 1 deletion simphony/core/cuba.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class CUBA(Enum):
CONCENTRATION = "CONCENTRATION"
CONDITION = "CONDITION"
CONSTANT_ELECTROSTATIC_FIELD_MODEL = "CONSTANT_ELECTROSTATIC_FIELD_MODEL"
CONSTANT_PRESSURE_CONDITION = "CONSTANT_PRESSURE_CONDITION"
CONSTANT_VELOCITY_CONDITION = "CONSTANT_VELOCITY_CONDITION"
CONSTANT_VOLUME_FRACTION_CONDITION = "CONSTANT_VOLUME_FRACTION_CONDITION"
CONTACT_ANGLE = "CONTACT_ANGLE"
CONTINUUM = "CONTINUUM"
COULOMB = "COULOMB"
Expand Down Expand Up @@ -74,7 +77,7 @@ class CUBA(Enum):
ELECTRON_MASS = "ELECTRON_MASS"
ELECTROSTATIC_FIELD = "ELECTROSTATIC_FIELD"
ELECTROSTATIC_MODEL = "ELECTROSTATIC_MODEL"
EMPTY = "EMPTY"
EMPTY_CONDITION = "EMPTY_CONDITION"
ENERGY = "ENERGY"
ENERGY_WELL_DEPTH = "ENERGY_WELL_DEPTH"
ENGINE = "ENGINE"
Expand Down Expand Up @@ -166,6 +169,8 @@ class CUBA(Enum):
PATCH = "PATCH"
PERIODIC = "PERIODIC"
PHASE_INTERACTION_STRENGTH = "PHASE_INTERACTION_STRENGTH"
PHASE_VOLUME_FRACTION = "PHASE_VOLUME_FRACTION"
PHASE_VOLUME_FRACTIONS = "PHASE_VOLUME_FRACTIONS"
PHYSICS_EQUATION = "PHYSICS_EQUATION"
POINT = "POINT"
POISSON_RATIO = "POISSON_RATIO"
Expand All @@ -184,6 +189,7 @@ class CUBA(Enum):
RESTITUTION_COEFFICIENT = "RESTITUTION_COEFFICIENT"
RHEOLOGY_MODEL = "RHEOLOGY_MODEL"
RHOMBOHEDRAL_LATTICE = "RHOMBOHEDRAL_LATTICE"
ROBIN = "ROBIN"
ROLLING_FRICTION = "ROLLING_FRICTION"
SCALING_COEFFICIENT = "SCALING_COEFFICIENT"
SHAPE_CENTER = "SHAPE_CENTER"
Expand Down Expand Up @@ -237,4 +243,7 @@ class CUBA(Enum):
VOLUME_FRACTION_GRADIENT = "VOLUME_FRACTION_GRADIENT"
WETTING_ANGLE = "WETTING_ANGLE"
YOUNG_MODULUS = "YOUNG_MODULUS"
ZERO_GRADIENT_PRESSURE_CONDITION = "ZERO_GRADIENT_PRESSURE_CONDITION"
ZERO_GRADIENT_VELOCITY_CONDITION = "ZERO_GRADIENT_VELOCITY_CONDITION"
ZERO_GRADIENT_VOLUME_FRACTION_CONDITION = "ZERO_GRADIENT_VOLUME_FRACTION_CONDITION" # noqa
ZETA_POTENTIAL = "ZETA_POTENTIAL"
79 changes: 71 additions & 8 deletions simphony/core/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@
dtype=None),
'BOUNDARY': Keyword(
name='Boundary',
definition='A computational boundary in the system, it includes translated physical boundaries to computational boundaries.', # noqa
definition='A computational boundary in the system, it includes translated physical boundaries to computational boundaries and a list of conditions operating on it.', # noqa
key='BOUNDARY',
shape=[1],
length=None,
Expand Down Expand Up @@ -1010,6 +1010,27 @@
shape=[1],
length=None,
dtype=None),
'CONSTANT_PRESSURE_CONDITION': Keyword(
name='ConstantPressureCondition',
definition='Constant pressure condition', # noqa
key='CONSTANT_PRESSURE_CONDITION',
shape=[1],
length=None,
dtype=None),
'CONSTANT_VELOCITY_CONDITION': Keyword(
name='ConstantVelocityCondition',
definition='Constant velocity condition', # noqa
key='CONSTANT_VELOCITY_CONDITION',
shape=[1],
length=None,
dtype=None),
'CONSTANT_VOLUME_FRACTION_CONDITION': Keyword(
name='ConstantVolumeFractionCondition',
definition='Constant volume fraction condition', # noqa
key='CONSTANT_VOLUME_FRACTION_CONDITION',
shape=[1],
length=None,
dtype=None),
'CONTINUUM': Keyword(
name='Continuum',
definition='Continuum model category according to the RoMM', # noqa
Expand Down Expand Up @@ -1082,7 +1103,7 @@
dtype=None),
'DIRICHLET': Keyword(
name='Dirichlet',
definition='Dirichlet boundary condition, specify the value the solutions takes on the boundary of the domain', # noqa
definition='Dirichlet boundary condition to specify the value the solutions takes on the boundary of the domain.', # noqa
key='DIRICHLET',
shape=[1],
length=None,
Expand Down Expand Up @@ -1115,10 +1136,10 @@
shape=[1],
length=None,
dtype=None),
'EMPTY': Keyword(
name='Empty',
definition='Empty boundary condition', # noqa
key='EMPTY',
'EMPTY_CONDITION': Keyword(
name='EmptyCondition',
definition='an entity to represent that no condition is applied on that domain or entitiy(ies)', # noqa
key='EMPTY_CONDITION',
shape=[1],
length=None,
dtype=None),
Expand Down Expand Up @@ -1376,7 +1397,7 @@
dtype=None),
'NEUMANN': Keyword(
name='Neumann',
definition='Neumann boundary condition, it specifies the values that the derivative of a solution is to take on the boundary of the domain.', # noqa
definition='Neumann boundary condition, it specifies the values that the derivative of a solution with respect to the variable is to take on the boundary of the domain.', # noqa
key='NEUMANN',
shape=[1],
length=None,
Expand Down Expand Up @@ -1444,6 +1465,20 @@
shape=[1],
length=None,
dtype=None),
'PHASE_VOLUME_FRACTION': Keyword(
name='PhaseVolumeFraction',
definition='volume fraction of a (one) phase (material) on a dataset entity', # noqa
key='PHASE_VOLUME_FRACTION',
shape=[1],
length=None,
dtype=None),
'PHASE_VOLUME_FRACTIONS': Keyword(
name='PhaseVolumeFractions',
definition='volume fractions for a number of phases (material) on a dataset entity', # noqa
key='PHASE_VOLUME_FRACTIONS',
shape=[1],
length=None,
dtype=None),
'PHYSICS_EQUATION': Keyword(
name='PhysicsEquation',
definition='Physics equation', # noqa
Expand Down Expand Up @@ -1493,6 +1528,13 @@
shape=[1],
length=None,
dtype=None),
'ROBIN': Keyword(
name='Robin',
definition='A mixed boundary condition $\alpha \Phi (x) + \beta (x) \partial {\Phi} / \partial {\bf{n}} (x) = h(x)$, with $h$ is the value.', # noqa
key='ROBIN',
shape=[1],
length=None,
dtype=None),
'SHEAR_STRESS_POWER_LAW_SLIP_VELOCITY': Keyword(
name='ShearStressPowerLawSlipVelocity',
definition='Shear stress power law dependant slip velocity boundary condition. Nonlinear boundary condition for wall tangential velocity of the form v_s = CUBA.LINEAR_CONSTANT * S^CUBA.POWER_LAW_INDEX where v_s is the slip velocity (tangential velocity on the wall) and S is the wall shear stress', # noqa
Expand Down Expand Up @@ -1628,9 +1670,30 @@
dtype=None),
'WETTING_ANGLE': Keyword(
name='WettingAngle',
definition='Volume fraction wall boundary condition with specified contact angle', # noqa
definition='Wetting angle Volume fraction wall boundary condition', # noqa
key='WETTING_ANGLE',
shape=[1],
length=None,
dtype=None),
'ZERO_GRADIENT_PRESSURE_CONDITION': Keyword(
name='ZeroGradientPressureCondition',
definition='Zero gradient pressure condition', # noqa
key='ZERO_GRADIENT_PRESSURE_CONDITION',
shape=[1],
length=None,
dtype=None),
'ZERO_GRADIENT_VELOCITY_CONDITION': Keyword(
name='ZeroGradientVelocityCondition',
definition='Zero gradient velocity condition', # noqa
key='ZERO_GRADIENT_VELOCITY_CONDITION',
shape=[1],
length=None,
dtype=None),
'ZERO_GRADIENT_VOLUME_FRACTION_CONDITION': Keyword(
name='ZeroGradientVolumeFractionCondition',
definition='Zero gradient volume fraction condition', # noqa
key='ZERO_GRADIENT_VOLUME_FRACTION_CONDITION',
shape=[1],
length=None,
dtype=None),
}
11 changes: 10 additions & 1 deletion simphony/cuds/meta/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
from .computational_model import ComputationalModel # noqa
from .condition import Condition # noqa
from .constant_electrostatic_field_model import ConstantElectrostaticFieldModel # noqa
from .constant_pressure_condition import ConstantPressureCondition # noqa
from .constant_velocity_condition import ConstantVelocityCondition # noqa
from .constant_volume_fraction_condition import ConstantVolumeFractionCondition # noqa
from .continuum import Continuum # noqa
from .coulomb import Coulomb # noqa
from .coulomb_friction_force import CoulombFrictionForce # noqa
Expand All @@ -35,7 +38,7 @@
from .edge import Edge # noqa
from .electronic import Electronic # noqa
from .electrostatic_model import ElectrostaticModel # noqa
from .empty import Empty # noqa
from .empty_condition import EmptyCondition # noqa
from .engine import Engine # noqa
from .engine_feature import EngineFeature # noqa
from .face import Face # noqa
Expand Down Expand Up @@ -82,13 +85,16 @@
from .particle import Particle # noqa
from .particles import Particles # noqa
from .periodic import Periodic # noqa
from .phase_volume_fraction import PhaseVolumeFraction # noqa
from .phase_volume_fractions import PhaseVolumeFractions # noqa
from .physics_equation import PhysicsEquation # noqa
from .point import Point # noqa
from .power_law_viscosity_model import PowerLawViscosityModel # noqa
from .primitive_cell import PrimitiveCell # noqa
from .relative_velocity_model import RelativeVelocityModel # noqa
from .rheology_model import RheologyModel # noqa
from .rhombohedral_lattice import RhombohedralLattice # noqa
from .robin import Robin # noqa
from .shear_stress_power_law_slip_velocity import ShearStressPowerLawSlipVelocity # noqa
from .simple_relative_velocity_model import SimpleRelativeVelocityModel # noqa
from .single_phase_model import SinglePhaseModel # noqa
Expand All @@ -109,3 +115,6 @@
from .verlet import Verlet # noqa
from .version import Version # noqa
from .wetting_angle import WettingAngle # noqa
from .zero_gradient_pressure_condition import ZeroGradientPressureCondition # noqa
from .zero_gradient_velocity_condition import ZeroGradientVelocityCondition # noqa
from .zero_gradient_volume_fraction_condition import ZeroGradientVolumeFractionCondition # noqa
5 changes: 3 additions & 2 deletions simphony/cuds/meta/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
class Boundary(CUDSComponent):
"""
A computational boundary in the system, it includes
translated physical boundaries to computational boundaries.
translated physical boundaries to computational boundaries
and a list of conditions operating on it.
"""
cuba_key = CUBA.BOUNDARY

Expand All @@ -24,7 +25,7 @@ def supported_parameters(cls):
return tuple(set((CUBA.CONDITION, ) + base_params))

def _default_definition(self):
return "A computational boundary in the system, it includes translated physical boundaries to computational boundaries." # noqa
return "A computational boundary in the system, it includes translated physical boundaries to computational boundaries and a list of conditions operating on it." # noqa

def _init_condition(self, value):
if value is Default:
Expand Down
4 changes: 2 additions & 2 deletions simphony/cuds/meta/box.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from simphony.core import Default # noqa
from .empty import Empty
from .empty_condition import EmptyCondition
from .boundary import Boundary
from simphony.core.cuba import CUBA
from simphony.cuds import meta_validation
Expand Down Expand Up @@ -59,7 +59,7 @@ def _validate_condition(self, value):
return value

def _default_condition(self):
return [Empty(), Empty(), Empty()]
return [EmptyCondition(), EmptyCondition(), EmptyCondition()]

def _init_vector(self, value):
if value is Default:
Expand Down
63 changes: 63 additions & 0 deletions simphony/cuds/meta/constant_pressure_condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from simphony.core import Default # noqa
from simphony.cuds import meta_validation
from simphony.core.cuba import CUBA
from .dirichlet import Dirichlet


class ConstantPressureCondition(Dirichlet):
"""
Constant pressure condition
"""
cuba_key = CUBA.CONSTANT_PRESSURE_CONDITION

def __init__(self, pressure, material, description=Default, name=Default):
super(ConstantPressureCondition, self).__init__(
material=material, description=description, name=name)
self._init_models()
self._init_pressure(pressure)

@classmethod
def supported_parameters(cls):
try:
base_params = super(ConstantPressureCondition,
cls).supported_parameters()
except AttributeError:
base_params = ()
return tuple(set((CUBA.PRESSURE, ) + 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 "Constant pressure condition" # noqa

def _init_pressure(self, value):
if value is Default:
value = self._default_pressure()

self.pressure = value

@property
def pressure(self):
return self.data[CUBA.PRESSURE]

@pressure.setter
def pressure(self, value):
value = self._validate_pressure(value)
self.data[CUBA.PRESSURE] = value

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

def _default_pressure(self):
raise TypeError("No default for pressure")
63 changes: 63 additions & 0 deletions simphony/cuds/meta/constant_velocity_condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from simphony.core import Default # noqa
from simphony.cuds import meta_validation
from simphony.core.cuba import CUBA
from .dirichlet import Dirichlet


class ConstantVelocityCondition(Dirichlet):
"""
Constant velocity condition
"""
cuba_key = CUBA.CONSTANT_VELOCITY_CONDITION

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

@classmethod
def supported_parameters(cls):
try:
base_params = super(ConstantVelocityCondition,
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 "Constant velocity condition" # 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")

0 comments on commit b7d24bc

Please sign in to comment.