From ec17c7eb12f94aeb3a8d9e587910fe7485bcf800 Mon Sep 17 00:00:00 2001 From: JuliusSaitz Date: Tue, 11 Jun 2024 15:11:29 +0200 Subject: [PATCH 1/3] add parameters to enable_harmonic_force --- pyaedt/maxwell.py | 71 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index fb63f86563f..d1b24a057ad 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -1685,29 +1685,59 @@ def enable_harmonic_force( objects, force_type=0, window_function="Rectangular", - use_number_of_last_cycles=True, - last_cycles_number=1, + use_number_of_cycles_from_stop_time=True, + number_of_cycles_from_stop_time=1, + start_time="0s", + use_number_of_cycles_for_stop_time=True, + number_of_cycles_for_stop_time=1, + stop_time="0.01s", + output_frequency_range_type="Use All", + output_frequency_range_start="0Hz", + number_of_output_frequencies=10, + output_frequency_range_stop = "1000Hz", calculate_force="Harmonic", + enable_inverter_feedback=False ): """Enable the harmonic force calculation for the transient analysis. Parameters ---------- objects : list - List of object names for force calculations. + Defines a list of object names for force calculations, for example: ["arc_01","arc_02","arc_03"] force_type : int, optional - Force Type. ``0`` for Objects, ``1`` for Surface, ``2`` for volumetric. + Force Type. ``0`` for Object Based, ``1`` for Element Based (Surface), ``2`` for Element Based (Volumetric). window_function : str, optional Windowing function. Default is ``"Rectangular"``. Available options are: ``"Rectangular"``, ``"Tri"``, ``"Van Hann"``, ``"Hamming"``, ``"Blackman"``, ``"Lanczos"``, ``"Welch"``. - use_number_of_last_cycles : bool, optional - Use number Of last cycles for force calculations. Default is ``True``. - last_cycles_number : int, optional - Defines the number of cycles to compute if `use_number_of_last_cycle` is ``True``. - calculate_force : sr, optional + use_number_of_cycles_from_stop_time : bool, optional + If True, the harmonic force will be computed using the transient force during the defined number of cycles backwards from stop time. + If False, the defined time range will be used. Default is ``True``. + number_of_cycles_from_stop_time : int, optional + Defines the number of cycles from stop time for harmonic force computation, if `use_number_of_cycles_from_stop_time` is ``True``. + start_time : str, optional + Defines the time range start time for harmonic force computation, if `use_number_of_cycles_from_stop_time` is ``False``. + use_number_of_cycles_for_stop_time : bool, optional + If True, the time range stop time is defined using the number of cycles. + The harmonic force will be computed using the defined number of cycles forward from the start time. + If False, the time range stop time is defined using the stop time. + The harmonic force will be computed using the transient force between the start time and the stop time. + Default is ``True``. + number_of_cycles_for_stop_time + Defines the time range for harmonic force computation using the number of cycles, if `use_number_of_cycles_for_stop_time` is ``True``. + stop_time : str, optional + Defines the time range stop time for harmonic force computation, if `use_number_of_cycles_for_stop_time` is ``False``. + output_frequency_range_type : str, optional + Defines the type of the output frequency range. Default is ``"Use All"``. + Available options are: ``"Use All"``, ``"Use Number"``, ``"Use Range"``. + output_frequency_range_start : str, optional + output_frequency_range_number : int, optional + Number of frequencies to output. + output_frequency_range_stop : str, optional + calculate_force : str, optional How to calculate force. The default is ``"Harmonic"``. - Options are ``"Harmonic"`` and ``"Transient"``. + Options are ``"Harmonic"``, ``"Transient"`` and ``"Harmonic and Transient"`` + enable_inverter_feedback : bool, optional Returns @@ -1729,21 +1759,24 @@ def enable_harmonic_force( "WindowFunctionType:=", window_function, "UseNumberOfLastCycles:=", - use_number_of_last_cycles, + use_number_of_cycles_from_stop_time, "NumberOfLastCycles:=", - last_cycles_number, + number_of_cycles_from_stop_time, "StartTime:=", - "0s", + start_time, "UseNumberOfCyclesForStopTime:=", - True, + use_number_of_cycles_for_stop_time, "NumberOfCyclesForStopTime:=", - 1, + number_of_cycles_for_stop_time, "StopTime:=", - "0.01s", + stop_time, "OutputFreqRangeType:=", - "Use All", - "CaculateForceType:=", - calculate_force + " Force", + output_frequency_range_type, + "OutputFreqRangeStart:=", output_frequency_range_start, + "OutputFreqRangeNum:=", str(number_of_output_frequencies), + "OutputFreqRangeStop:=", output_frequency_range_stop, + "CaculateForceType:=", calculate_force + " Force", + "EnableInverterFeedback:=", enable_inverter_feedback ] ) return True From 69ba7e775dc6222fefd2fb3af848a185cb07ac4d Mon Sep 17 00:00:00 2001 From: JuliusSaitz Date: Tue, 11 Jun 2024 16:01:15 +0200 Subject: [PATCH 2/3] add parameters to enable_harmonic_force --- pyaedt/maxwell.py | 79 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index 0d5ead781d7..46d7414605d 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -1706,32 +1706,62 @@ def assign_radiation(self, assignment, radiation=None): @pyaedt_function_handler(objects="assignment") def enable_harmonic_force( self, - assignment, + objects, force_type=0, window_function="Rectangular", - use_number_of_last_cycles=True, - last_cycles_number=1, + use_number_of_cycles_from_stop_time=True, + number_of_cycles_from_stop_time=1, + start_time="0s", + use_number_of_cycles_for_stop_time=True, + number_of_cycles_for_stop_time=1, + stop_time="0.01s", + output_frequency_range_type="Use All", + output_frequency_range_start="0Hz", + number_of_output_frequencies=10, + output_frequency_range_stop = "1000Hz", calculate_force="Harmonic", + enable_inverter_feedback=False ): """Enable the harmonic force calculation for the transient analysis. Parameters ---------- - assignment : list - List of object names for force calculations. + objects : list + Defines a list of object names for force calculations, for example: ["arc_01","arc_02","arc_03"] force_type : int, optional - Force type. Options are ``0`` for objects, ``1`` for surface, and ``2`` for volumetric. + Force Type. ``0`` for Object Based, ``1`` for Element Based (Surface), ``2`` for Element Based (Volumetric). window_function : str, optional Windowing function. Default is ``"Rectangular"``. Available options are: ``"Rectangular"``, ``"Tri"``, ``"Van Hann"``, ``"Hamming"``, ``"Blackman"``, ``"Lanczos"``, ``"Welch"``. - use_number_of_last_cycles : bool, optional - Use number of last cycles for force calculations. Default is ``True``. - last_cycles_number : int, optional - Defines the number of cycles to compute if `use_number_of_last_cycle` is ``True``. - calculate_force : sr, optional + use_number_of_cycles_from_stop_time : bool, optional + If True, the harmonic force will be computed using the transient force during the defined number of cycles backwards from stop time. + If False, the defined time range will be used. Default is ``True``. + number_of_cycles_from_stop_time : int, optional + Defines the number of cycles from stop time for harmonic force computation, if `use_number_of_cycles_from_stop_time` is ``True``. + start_time : str, optional + Defines the time range start time for harmonic force computation, if `use_number_of_cycles_from_stop_time` is ``False``. + use_number_of_cycles_for_stop_time : bool, optional + If True, the time range stop time is defined using the number of cycles. + The harmonic force will be computed using the defined number of cycles forward from the start time. + If False, the time range stop time is defined using the stop time. + The harmonic force will be computed using the transient force between the start time and the stop time. + Default is ``True``. + number_of_cycles_for_stop_time + Defines the time range for harmonic force computation using the number of cycles, if `use_number_of_cycles_for_stop_time` is ``True``. + stop_time : str, optional + Defines the time range stop time for harmonic force computation, if `use_number_of_cycles_for_stop_time` is ``False``. + output_frequency_range_type : str, optional + Defines the type of the output frequency range. Default is ``"Use All"``. + Available options are: ``"Use All"``, ``"Use Number"``, ``"Use Range"``. + output_frequency_range_start : str, optional + output_frequency_range_number : int, optional + Number of frequencies to output. + output_frequency_range_stop : str, optional + calculate_force : str, optional How to calculate force. The default is ``"Harmonic"``. - Options are ``"Harmonic"`` and ``"Transient"``. + Options are ``"Harmonic"``, ``"Transient"`` and ``"Harmonic and Transient"`` + enable_inverter_feedback : bool, optional Returns @@ -1743,31 +1773,34 @@ def enable_harmonic_force( if self.solution_type != "Transient": self.logger.error("This methods work only with Maxwell Transient Analysis.") return False - assignment = self.modeler.convert_to_selections(assignment, True) + objects = self.modeler.convert_to_selections(objects, True) self.odesign.EnableHarmonicForceCalculation( [ "EnabledObjects:=", - assignment, + objects, "ForceType:=", force_type, "WindowFunctionType:=", window_function, "UseNumberOfLastCycles:=", - use_number_of_last_cycles, + use_number_of_cycles_from_stop_time, "NumberOfLastCycles:=", - last_cycles_number, + number_of_cycles_from_stop_time, "StartTime:=", - "0s", + start_time, "UseNumberOfCyclesForStopTime:=", - True, + use_number_of_cycles_for_stop_time, "NumberOfCyclesForStopTime:=", - 1, + number_of_cycles_for_stop_time, "StopTime:=", - "0.01s", + stop_time, "OutputFreqRangeType:=", - "Use All", - "CaculateForceType:=", - calculate_force + " Force", + output_frequency_range_type, + "OutputFreqRangeStart:=", output_frequency_range_start, + "OutputFreqRangeNum:=", str(number_of_output_frequencies), + "OutputFreqRangeStop:=", output_frequency_range_stop, + "CaculateForceType:=", calculate_force + " Force", + "EnableInverterFeedback:=", enable_inverter_feedback ] ) return True From 9fc52fef1836ece2cd0d3b1bf7163199870cd87d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 08:41:50 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyaedt/maxwell.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index 46d7414605d..eb46ce4fadb 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -1718,9 +1718,9 @@ def enable_harmonic_force( output_frequency_range_type="Use All", output_frequency_range_start="0Hz", number_of_output_frequencies=10, - output_frequency_range_stop = "1000Hz", + output_frequency_range_stop="1000Hz", calculate_force="Harmonic", - enable_inverter_feedback=False + enable_inverter_feedback=False, ): """Enable the harmonic force calculation for the transient analysis. @@ -1796,11 +1796,16 @@ def enable_harmonic_force( stop_time, "OutputFreqRangeType:=", output_frequency_range_type, - "OutputFreqRangeStart:=", output_frequency_range_start, - "OutputFreqRangeNum:=", str(number_of_output_frequencies), - "OutputFreqRangeStop:=", output_frequency_range_stop, - "CaculateForceType:=", calculate_force + " Force", - "EnableInverterFeedback:=", enable_inverter_feedback + "OutputFreqRangeStart:=", + output_frequency_range_start, + "OutputFreqRangeNum:=", + str(number_of_output_frequencies), + "OutputFreqRangeStop:=", + output_frequency_range_stop, + "CaculateForceType:=", + calculate_force + " Force", + "EnableInverterFeedback:=", + enable_inverter_feedback, ] ) return True