Source code for outputs.link_displacement.api.link_displacement_api

import typing
from more.api.simulation.output_cases.output_setup import OutputSetup, TranslationSettableMixin, RotationSettableMixin
from more.api.utils.interface_registries import register_api_implementation
from more.outputs.link_displacement import LinkDisplacement
from more.log import get_logger
logger = get_logger(__name__)





def _link_displacement_api_setup(api):
    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')
    return oc_setup.create_output_setup(output_type='Link displacement')


[docs] @register_api_implementation(core_class=LinkDisplacement) class LinkDisplacementSetup(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] def set_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}) return self
[docs] def set_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}) return self
[docs] def set_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}) return self
[docs] def set_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}) return self
[docs] def set_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}) return self
[docs] def set_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}) return self
[docs] def set_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) return self
[docs] def set_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 """ return self.set_dof_dict(dof_values_dict={dof_name: value})