[docs]@register_api_implementation(core_class=LinkDisplacement)classLinkDisplacementSetup(OutputSetup,TranslationSettableMixin,RotationSettableMixin):""" The API handler for link outputs The following example shows how to create a link output 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() >>> occ_setup = simulation_setup.create_output_case_container_setup().set_name(name='Example OCC') >>> oc_setup = occ_setup.create_output_case_setup(oc_type='Mechanical output case').set_name(name='Example OC') >>> link_displacement_setup = oc_setup.create_output_setup(output_type='Link displacement') .. >>> isinstance(link_displacement_setup, LinkDisplacementSetup) True >>> isinstance(link_displacement_setup._output, LinkDisplacement) True The next example shows how to get an API object for an already existing output. .. 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() >>> occ_setup = simulation_setup.create_output_case_container_setup().set_name(name='Example OCC') >>> oc_setup = occ_setup.create_output_case_setup(oc_type='Mechanical output case').set_name(name='Example OC') .. >>> link_displacement_setup = oc_setup.create_output_setup(output_type='Link displacement') >>> link_displacement_setup = oc_setup.get_output_setup(index=0) # The output under this index must already exist .. >>> isinstance(link_displacement_setup, LinkDisplacementSetup) True >>> isinstance(link_displacement_setup._output, LinkDisplacement) True """
[docs]defset_u(self,value:float)->'LinkDisplacementSetup':""" Sets the 'u' value of the output vector See example at the top for how to create a link output setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> link_displacement_setup = _link_displacement_api_setup(api) >>> link_displacement_setup = link_displacement_setup.set_u(value=10) .. >>> link_displacement_setup._output.generalized_dof_vector.u == 10 True >>> link_displacement_setup.set_u(value='wrong value') Traceback (most recent call last): ... TypeError: ... Returns ------- self: LinkDisplacementSetup Raises ------ TypeError Raised if the supplied value is not a floating point number """self.set_dof_dict(dof_values_dict={'u':value})returnself
[docs]defset_v(self,value:float)->'LinkDisplacementSetup':""" Sets the 'v' value of the output vector See example at the top for how to create a link output setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> link_displacement_setup = _link_displacement_api_setup(api) >>> link_displacement_setup = link_displacement_setup.set_v(value=10) .. >>> link_displacement_setup._output.generalized_dof_vector.v == 10 True >>> link_displacement_setup.set_v(value='wrong value') Traceback (most recent call last): ... TypeError: ... Returns ------- self: LinkDisplacementSetup Raises ------ TypeError Raised if the supplied value is not a floating point number """self.set_dof_dict(dof_values_dict={'v':value})returnself
[docs]defset_w(self,value:float)->'LinkDisplacementSetup':""" Sets the 'w' value of the output vector See example at the top for how to create a link output setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> link_displacement_setup = _link_displacement_api_setup(api) >>> link_displacement_setup = link_displacement_setup.set_w(value=10) .. >>> link_displacement_setup._output.generalized_dof_vector.w == 10 True >>> link_displacement_setup.set_w(value='wrong value') Traceback (most recent call last): ... TypeError: ... Returns ------- self: LinkDisplacementSetup Raises ------ TypeError Raised if the supplied value is not a floating point number """self.set_dof_dict(dof_values_dict={'w':value})returnself
[docs]defset_ru(self,value:float)->'LinkDisplacementSetup':""" Sets the 'ru' value of the output vector See example at the top for how to create a link output setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> link_displacement_setup = _link_displacement_api_setup(api) >>> link_displacement_setup = link_displacement_setup.set_ru(value=10) .. >>> link_displacement_setup._output.generalized_dof_vector.ru == 10 True >>> link_displacement_setup.set_ru(value='wrong value') Traceback (most recent call last): ... TypeError: ... Returns ------- self: LinkDisplacementSetup Raises ------ TypeError Raised if the supplied value is not a floating point number """self.set_dof_dict(dof_values_dict={'ru':value})returnself
[docs]defset_rv(self,value:float)->'LinkDisplacementSetup':""" Sets the 'rv' value of the output vector See example at the top for how to create a link output setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> link_displacement_setup = _link_displacement_api_setup(api) >>> link_displacement_setup = link_displacement_setup.set_rv(value=10) .. >>> link_displacement_setup._output.generalized_dof_vector.rv == 10 True >>> link_displacement_setup.set_rv(value='wrong value') Traceback (most recent call last): ... TypeError: ... Returns ------- self: LinkDisplacementSetup Raises ------ TypeError Raised if the supplied value is not a floating point number """self.set_dof_dict(dof_values_dict={'rv':value})returnself
[docs]defset_rw(self,value:float)->'LinkDisplacementSetup':""" Sets the 'rw' value of the output vector See example at the top for how to create a link output setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> link_displacement_setup = _link_displacement_api_setup(api) >>> link_displacement_setup = link_displacement_setup.set_rw(value=10) .. >>> link_displacement_setup._output.generalized_dof_vector.rw == 10 True >>> link_displacement_setup.set_rw(value='wrong value') Traceback (most recent call last): ... TypeError: ... Returns ------- self: LinkDisplacementSetup Raises ------ TypeError Raised if the supplied value is not a floating point number """self.set_dof_dict(dof_values_dict={'rw':value})returnself
[docs]defset_dof_dict(self,dof_values_dict:typing.Dict[str,float])->'LinkDisplacementSetup':""" Sets the values of the output vector to those given in the dictionary See example at the top for how to create a link output setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> link_displacement_setup = _link_displacement_api_setup(api) >>> link_displacement_setup = link_displacement_setup.set_dof_dict(dof_values_dict={'u': 5, 'ru': 10, 'v': 2.0}) .. >>> link_displacement_setup._output.generalized_dof_vector.u == 5 True >>> link_displacement_setup._output.generalized_dof_vector.ru == 10 True >>> link_displacement_setup._output.generalized_dof_vector.v == 2.0 True >>> link_displacement_setup.set_dof_dict(dof_values_dict={'u': 'wrong value'}) Traceback (most recent call last): ... TypeError: ... >>> link_displacement_setup.set_dof_dict(dof_values_dict={'wrong dof': 10}) Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Returns ------- self: LinkDisplacementSetup 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._output.generalized_dof_vector.set_dof_dict(dof_values_dict=dof_values_dict)returnself
[docs]defset_link_by_name(self,link_name:str)->'LinkDisplacementSetup':""" Sets the link for the associated link output See example at the top for how to create a link output setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> link_displacement_setup = _link_displacement_api_setup(api) >>> link = proj.comp.add_link(physics='mech') >>> link.name = 'example link' >>> link_displacement_setup = link_displacement_setup.set_link_by_name(link_name='example link') # The link with this name must already exist .. >>> link_displacement_setup._output.link_selector.selected_entity == link True >>> link_displacement_setup = link_displacement_setup.set_link_by_name(link_name='nonexistent name') Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Returns ------- self: LinkDisplacementSetup Raises ------ NameNotFoundError Raised if the supplied link name was not found """self._output.link_selector.select_entity_by_name(name=link_name)returnself
[docs]defset_link(self,link)->'LinkDisplacementSetup':""" Deprecated method .. admonition:: Deprecated :class: warning `set_link` will be removed in a future MORe release, it is replaced by :meth:`~.set_link_by_name` """logger.warning('Deprecation: \"set_link\" will be removed in a future MORe release, it is replaced by \"set_link_by_name\"')returnself.set_link_by_name(link_name=link.name)
[docs]defset_dof(self,dof_name,value)->'LinkDisplacementSetup':""" 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) >>> link_displacement_setup = _link_displacement_api_setup(api) >>> link_displacement_setup = link_displacement_setup.set_dof(dof_name='v', value=10) .. >>> link_displacement_setup._output.generalized_dof_vector.v == 10 True >>> link_displacement_setup.set_dof(dof_name='v', value='wrong value') Traceback (most recent call last): ... TypeError: ... >>> link_displacement_setup.set_dof(dof_name='wrong dof', value=10) Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Returns ------- self: LinkDisplacementSetup Raises ------ TypeError Raised if the supplied value is not a floating point number NameNotFoundError Raised if the given name is not a recognized DOF """returnself.set_dof_dict(dof_values_dict={dof_name:value})