[docs]@register_api_implementation(core_class=Convection)classConvectionSetup(LoadSetup):""" The API handler for convection loads The following example shows how to create a convection using the API, it is assumed that these steps were performed in each of the examples for other methods in this class. .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> simulation_setup = api.create_simulation_setup() >>> lcc_setup = simulation_setup.create_load_case_container_setup().set_name(name='Example LCC') >>> lc_setup = lcc_setup.create_load_case_setup(lc_type='Thermal load case').set_name(name='Example LC') >>> load_setup = lc_setup.create_load_setup(load_type='Convection') .. >>> isinstance(load_setup, ConvectionSetup) True >>> isinstance(load_setup._load, Convection) True The next example shows how to get an API object for an already existing load. .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> simulation_setup = api.create_simulation_setup() >>> lcc_setup = simulation_setup.create_load_case_container_setup().set_name(name='Example LCC') >>> lc_setup = lcc_setup.create_load_case_setup(lc_type='Thermal load case').set_name(name='Example LC') .. >>> load_setup = lc_setup.create_load_setup(load_type='Convection') >>> load_setup = lc_setup.get_load_setup(index=0) # The load under this index must already exist .. >>> isinstance(load_setup, ConvectionSetup) True >>> isinstance(load_setup._load, Convection) True """
[docs]defset_value(self,value)->'ConvectionSetup':""" Sets the value of the convection See example at the top for how to create a convection setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> load_setup = _convection_api_setup(api) >>> load_setup = load_setup.set_value(value=20) .. >>> load_setup._load.generalized_force_vector.value == 20 True >>> load_setup.set_value(value='wrong value') Traceback (most recent call last): ... TypeError: ... Returns ------- self: ConvectionSetup Raises ------ TypeError Raised if the supplied value is not a floating point number """self.set_dof_dict(dof_values_dict={'value':value})returnself
[docs]defset_dof_dict(self,dof_values_dict:typing.Dict[str,float])->'ConvectionSetup':""" Sets the values of the DOF vector to those given in the dictionary See example at the top for how to create a convection setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> load_setup = _convection_api_setup(api) >>> load_setup = load_setup.set_dof_dict(dof_values_dict={'value': 20}) .. >>> load_setup._load.generalized_force_vector.value == 20 True >>> load_setup.set_dof_dict(dof_values_dict={'value': 'wrong value'}) Traceback (most recent call last): ... TypeError: ... >>> load_setup.set_dof_dict(dof_values_dict={'wrong dof': 10}) Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Returns ------- self: ConvectionSetup Raises ------ TypeError Raised if the supplied value is not a floating point number NameNotFoundError Raised if a key in the supplied dictionary is not a recognized dof """self._load.generalized_force_vector.set_dof_dict(dof_values_dict=dof_values_dict)returnself
[docs]defset_component_by_name(self,component_name:str)->'ConvectionSetup':""" Sets the component for the associated convection See example at the top for how to create a convection setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> load_setup = _convection_api_setup(api) >>> component = proj.comp.add_component() >>> component.name = 'example component' >>> load_setup = load_setup.set_component_by_name(component_name='example component') .. >>> load_setup._load.component_selector.selected_entity == component True >>> load_setup = load_setup.set_component_by_name(component_name='nonexistent name') Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Returns ------- self: ConvectionSetup Raises ------ NameNotFoundError Raised if the supplied name is not a recognized component """self._load.component_selector.select_entity_by_name(name=component_name)returnself
[docs]defset_interface_by_name(self,interface_name)->'ConvectionSetup':""" Sets the interface for the associated convection Returns ------- self: ConvectionSetup Raises ------ NameNotFoundError Raised if the supplied name is not recognized """try:self._load.selected_interface=self._available_interfaces_dict[interface_name]exceptKeyError:raiseNameNotFoundError('Interface with name: {} not found, available names are: {}'.format(interface_name,self._available_interfaces_dict.keys()))returnself
[docs]defset_dof(self,dof_name,value)->'ConvectionSetup':""" Sets the value of an element of the DOF vector See example at the top for how to create the setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> load_setup = _convection_api_setup(api) >>> load_setup = load_setup.set_dof(dof_name='value', value=10) .. >>> load_setup._load.generalized_force_vector.value == 10 True >>> load_setup.set_dof(dof_name='value', value='wrong value') Traceback (most recent call last): ... TypeError: ... >>> load_setup.set_dof(dof_name='wrong dof', value=10) Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Returns ------- self: ConvectionSetup Raises ------ TypeError Raised if the supplied value is not a floating point number NameNotFoundError Raised if there is no DOF with the given name """returnself.set_dof_dict(dof_values_dict={dof_name:value})
[docs]defset_temperature(self,value)->'ConvectionSetup':""" Deprecated version of :meth:`~.set_general_job_settings_parameter` .. admonition:: Deprecated :class: warning `set_convection` will be removed in a future MORe release, it is replaced by :meth:`~.set_temperature_value` """logger.warning('Deprecation: \"set_temperature\" will be removed in a future MORe release, replace with \"set_value\"')returnself.set_value(value)
[docs]defset_link(self,link)->'ConvectionSetup':""" Deprecated method .. admonition:: Deprecated :class: warning Convection no longer uses links. `set_link` will be removed in a future MORe release, it is replaced by :meth:`~.set_component_by_name` and :meth:`~.set_interface_by_name` """logger.warning('Deprecation: Convection no longer uses links. \"set_link\" will be removed in a future MORe release, it is replaced by \"set_component_by_name\" and \"set_interface_by_name\"')returnself.set_component_by_name(component_name=link.target_component.name).set_interface_by_name(interface_name=link.target_interface.name)
[docs]defset_link_by_name(self,link_name)->'ConvectionSetup':""" Deprecated method .. admonition:: Deprecated :class: error Convection no longer uses links. `set_link_by_name` will be removed in a future MORe release, it is replaced by :meth:`~.set_component_by_name` and :meth:`~.set_interface_by_name` """raiseMOReAPIError('Deprecation: Convection no longer uses links. \"set_link_by_name\" was removed, it is replaced by \"set_component_by_name\" and \"set_interface_by_name\"')