Currently, Robin BCs cant be written with ogs6py. I suggest the following change in processvars.py
def add_bc(self, **args):
"""
Adds a boundary condition.
Parameters
----------
process_variable_name : `str`
type : `str`
geometrical_set : `str`
geometry : `str`
component : `int` or `str`
parameter : `str`
bc_object : `str`
mesh : `str`
"""
self._convertargs(args)
if "process_variable_name" not in args:
raise KeyError("No process variable name specified.")
if "type" not in args:
raise KeyError("No type given.")
if args['process_variable_name'] not in self.tree['process_variables']['children']:
raise KeyError("You need to set initial condition for that process variable first.")
if "boundary_conditions" not in self.tree['process_variables']['children'][
args['process_variable_name']]['children']:
self.tree['process_variables']['children'][args['process_variable_name']]['children'][
'boundary_conditions'] = self.populate_tree('boundary_conditions', children={})
boundary_conditions = self.tree['process_variables'][
'children'][args['process_variable_name']]['children']['boundary_conditions']
if "geometrical_set" in args:
if "geometry" not in args:
raise KeyError("You need to provide a geometry.")
cpnts = args.get('component','0')
boundary_conditions['children'][args['geometrical_set']+args['geometry'] +
cpnts] = self.populate_tree('boundary_condition', children={})
boundary_condition = boundary_conditions['children'][
args['geometrical_set'] + args['geometry'] + cpnts]
boundary_condition['children']['type'] = self.populate_tree('type',
text=args['type'], children={})
boundary_condition['children']['geometrical_set'] = self.populate_tree(
'geometrical_set', text=args['geometrical_set'], children={})
boundary_condition['children']['geometry'] = self.populate_tree(
'geometry', text=args['geometry'], children={})
if "parameter" in args:
if "component" in args:
boundary_condition['children']['component'] = self.populate_tree(
'component', text=args['component'], children={})
boundary_condition['children']['parameter'] = self.populate_tree(
'parameter', text=args['parameter'], children={})
elif "bc_object" in args:
if "component" in args:
boundary_condition['children']['component'] = self.populate_tree(
'component', text=args['component'], children={})
boundary_condition['children']['bc_object'] = self.populate_tree(
'bc_object', text=args['bc_object'], children={})
else:
raise KeyError("Please provide the parameter for Dirichlet \
or Neumann BC/bc_object for Python BC")
elif "mesh" in args:
cpnts = args.get('component','0')
boundary_conditions['children'][args['mesh']+cpnts] = self.populate_tree(
'boundary_condition', children={})
boundary_condition = boundary_conditions['children'][args['mesh']+cpnts]
boundary_condition['children']['type'] = self.populate_tree('type',
text=args['type'], children={})
boundary_condition['children']['mesh'] = self.populate_tree(
'mesh', text=args['mesh'], children={})
if "parameter" in args:
if "component" in args:
boundary_condition['children']['component'] = self.populate_tree(
'component', text=args['component'], children={})
boundary_condition['children']['parameter'] = self.populate_tree(
'parameter', text=args['parameter'], children={})
elif "bc_object" in args:
if "component" in args:
boundary_condition['children']['component'] = self.populate_tree(
'component', text=args['component'], children={})
boundary_condition['children']['bc_object'] = self.populate_tree(
'bc_object', text=args['bc_object'], children={})
elif "u_0" in args:
if "alpha" in args:
boundary_condition['children']['alpha'] = self.populate_tree(
'alpha', text=args['alpha'], children={})
boundary_condition['children']['u_0'] = self.populate_tree(
'u_0', text=args['u_0'], children={})
else:
raise KeyError("Please provide the parameter for Dirichlet \
or Neumann BC/bc_object for Python BC")
else:
raise KeyError("You should provide either a geometrical set \
or a mesh to define BC for.")
Currently,
Robin
BCs cant be written with ogs6py. I suggest the following change inprocessvars.py