-
Notifications
You must be signed in to change notification settings - Fork 5
Add BSPM Machine Constants Analyzer to develop branch #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wchan29
wants to merge
17
commits into
develop
Choose a base branch
from
user/wchan29/bspm_constants_analyzer
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8b5fa72
Initial commit
wchan29 7ef9924
clean up code
wchan29 3db45ff
modify code
wchan29 3d6f5a4
add rst and csv
wchan29 512e258
add input csv and update rsy
wchan29 fd6420a
edit script
wchan29 1f50ee6
remove legacy code and unused python code
wchan29 e1c1929
edit rst docs
wchan29 d8c3e21
remove test.py
wchan29 adf52d2
Merge branch 'develop' into user/wchan29/bspm_constants_analyzer
dmnewman3 48b66de
Update language of .rst file
dmnewman3 2cfb98e
Merge branch 'develop' into user/wchan29/bspm_constants_analyzer
noguchi-takahiro 75092d9
Update jmag_2d to fix naming issue
noguchi-takahiro ebac992
address taka comment
wchan29 202eb35
change operating point variable name
wchan29 0daf357
update analyzer input and docs
wchan29 f73446a
type on delta symbol
wchan29 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
297 changes: 297 additions & 0 deletions
297
docs/source/EM_analyzers/bspm_mach_constants_analyzer.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,297 @@ | ||
| BSPM Machine Constants Analyzer | ||
| ######################################################################## | ||
|
|
||
| This analyzer determines the machine constants (:math:`k_t, k_f, k_\delta,` and :math:`k_\Phi`) of a given BSPM machine design. | ||
|
|
||
| Model Background | ||
| **************** | ||
|
|
||
| This analyzer utilizes scripts within eMach to generate ``BSPM_Machine`` and ``BSPM_Machine_Oper_Pt`` objects for performing a machine constant analysis. | ||
|
|
||
| Torque Contant :math:`k_t` | ||
| ------------------------------------ | ||
| The machine torque constant, :math:`k_t`, can be computed using the following expression: | ||
|
|
||
| .. math:: | ||
|
|
||
| \tau = k_t i_q | ||
|
|
||
| where :math:`\tau` is torque and :math:`i_q` is the torque current. | ||
|
|
||
| Suspension Force :math:`k_f` & Displacement Stiffness Constant :math:`k_\delta` | ||
| -------------------------------------------------------------------------------------------------- | ||
| The suspension force constant, :math:`k_f`, and displacement stiffness constant, :math:`k_\delta`, can be computed using the following expression: | ||
|
|
||
| .. math:: | ||
|
|
||
| \vec{F} = k_f \vec{i_s}+k_\delta \vec{\delta} | ||
|
|
||
| where :math:`\delta` is the displacement of the rotor from the magnetic center, :math:`F_c` is the force created by the current, :math:`\vec{i_s}` is the suspension | ||
| current, :math:`k_f` is the force constant, and :math:`k_\delta` is the displacement stiffness constant. | ||
|
|
||
|
|
||
| Back-EMF Constant :math:`k_\Phi` | ||
| ------------------------------------ | ||
| The machine back-EMF constant :math:`k_\Phi` can be expressed using the following equation: | ||
|
|
||
| .. math:: | ||
|
|
||
| \vec{v_m} = k_\Phi\omega | ||
|
|
||
| where, :math:`\omega` is angular velocity in rad/s and :math:`\vec{v_m}` is the RMS value of the induced phase voltage. | ||
|
|
||
| Input from User | ||
| ********************************* | ||
|
|
||
| To define the problem class, the user needs to provide the ``BSPM_Machine`` and ``BSPM_Machine_Oper_Pt`` objects, which specify both the properties and the operating | ||
| point of the BSPM machine intended for evaluation. For defining these objects, the user can refer to the :doc:`BSPM Design <../machines/bspm/index>` page. The inputs | ||
| for each are summarized below: | ||
|
|
||
| .. csv-table:: Input for BSPM machine constants problem class | ||
| :file: input_bspm_mach_constants_problem.csv | ||
| :widths: 20, 20, 30 | ||
| :header-rows: 1 | ||
|
|
||
| .. csv-table:: Input for BSPM machine constants analyzer class | ||
| :file: input_bspm_mach_constants_analyzer.csv | ||
| :widths: 20, 20, 30 | ||
| :header-rows: 1 | ||
|
|
||
| The default value of ``Kdelta_coords`` is shown below: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| Kdelta_coords: list = [[x, y] for x in np.linspace(-0.3,0.3,3) | ||
| for y in np.linspace(-0.3,0.3,3)], | ||
|
|
||
|
|
||
| Import Modules | ||
| ------------------------------------ | ||
| The following code imports all the required modules for performing a BSPM machine constants analysis. Users can paste this code into their scripts and execute it | ||
| to ensure the modules can imported properly: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import mach_eval.analyzers.electromagnetic.bspm.machine_constant.bspm_mach_constants as bmc | ||
| import mach_eval.analyzers.electromagnetic.bspm.machine_constant.bspm_mach_constants as bmc | ||
| from mach_eval.machines.materials.electric_steels import Arnon5 | ||
| from mach_eval.machines.materials.jmag_library_magnets import N40H | ||
| from mach_eval.machines.materials.miscellaneous_materials import ( | ||
| CarbonFiber, | ||
| Steel, | ||
| Copper, | ||
| Hub, | ||
| Air, | ||
| ) | ||
| from mach_eval.machines.bspm import BSPM_Machine | ||
| from mach_eval.machines.bspm.bspm_oper_pt import BSPM_Machine_Oper_Pt | ||
| from mach_eval.analyzers.electromagnetic.bspm.jmag_2d_config import JMAG_2D_Config | ||
| import os | ||
| import numpy as np | ||
wchan29 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Define and Create ``BSPM Machine`` Object | ||
| ------------------------------------------ | ||
|
|
||
| The user can paste the following sample BSPM machine design to create the ``BSPM_machine`` object: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| ######################################################### | ||
| # CREATE BSPM MACHINE OBJECT | ||
| ######################################################### | ||
|
|
||
| ################ DEFINE BP4 ################ | ||
| bspm_dimensions = { | ||
| "alpha_st": 31.7088, #[deg] | ||
| "d_so": 2.02334e-3, #[m] | ||
| "w_st": 5.95805e-3, #[m] | ||
| "d_st": 18.4967e-3, #[m] | ||
| "d_sy": 5.81374e-3, #[m] | ||
| "alpha_m": 180, #[m] | ||
| "d_m": 3e-3, #[m] | ||
| "d_mp": 0, #[m] | ||
| "d_ri": 0.1e-3, #[m] | ||
| "alpha_so": 15.5, #[deg] | ||
| "d_sp": 2.05e-3, #[m] | ||
| "r_si": 16.9737e-3, #[m] | ||
| "alpha_ms": 180, #[deg] | ||
| "d_ms": 0, #[m] | ||
| "r_sh": 8.9e-3, #[m] | ||
| "l_st": 25e-3, #[m] | ||
| "d_sl": 1e-3, #[m] | ||
| "delta_sl": 9.63e-5, #[m] | ||
| } | ||
|
|
||
| bspm_parameters = { | ||
| "p": 1, # number of pole pairs | ||
| "ps": 2, # number of suspension pole pairs | ||
| "n_m": 1, # | ||
| "Q": 6, # number of slots | ||
| "rated_speed": 16755.16, #[rad/s] | ||
| "rated_power": 8e3, # [W] | ||
| "rated_voltage": 8e3/18, # [V_rms] | ||
| "rated_current": 18, # [I_rms] | ||
| "name": "BP4" | ||
| } | ||
|
|
||
| bspm_materials = { | ||
| "air_mat": Air, | ||
| "rotor_iron_mat": Arnon5, | ||
| "stator_iron_mat": Arnon5, | ||
| "magnet_mat": N40H, | ||
| "rotor_sleeve_mat": CarbonFiber, | ||
| "coil_mat": Copper, | ||
| "shaft_mat": Steel, | ||
| "rotor_hub": Hub, | ||
| } | ||
|
|
||
| bspm_winding = { | ||
| "no_of_layers": 2, | ||
| # layer_phases is a list of lists, the number of lists = no_of_layers | ||
| # first list corresponds to coil sides in first layer | ||
| # second list corresponds to coil sides in second layer | ||
| # the index indicates the slot opening corresponding to the coil side | ||
| # string characters are used to represent the phases | ||
| "layer_phases": [["U", "W", "V", "U", "W", "V"], | ||
| ["V", "U", "W", "V", "U", "W"]], | ||
| # layer_polarity is a list of lists, the number of lists = no_of_layers | ||
| # first list corresponds to coil side direction in first layer | ||
| # second list corresponds to coil side direction in second layer | ||
| # the index indicates the slot opening corresponding to the coil side | ||
| # + indicates coil side goes into the page, - indicates coil side comes out of page | ||
| "layer_polarity": [["+", "-", "+", "-", "+", "-"], | ||
| ["+", "-", "+", "-", "+", "-"]], | ||
| # coil_groups are a unique property of DPNV windings | ||
| # coil group is assigned corresponding to the 1st winding layer | ||
| "coil_groups": ["b", "a", "b", "a", "b", "a"], | ||
| "pitch": 1, | ||
| "Z_q": 45, | ||
| "Kov": 1.8, | ||
| "Kcu": 0.5, | ||
| # add phase current offset to know relative rotor / current angle for creating Iq | ||
| "phase_current_offset": -30 | ||
| } | ||
|
|
||
| bp4 = BSPM_Machine( | ||
| bspm_dimensions, bspm_parameters, bspm_materials, bspm_winding | ||
| ) | ||
|
|
||
| Define and Create ``BSPM_Machine_Oper_Pt`` Object | ||
| ------------------------------------------------- | ||
|
|
||
| The users can paste the provided sample BSPM operating point code to instantiate the ``BSPM_Machine_Oper_Pt`` object: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| ######################################################### | ||
| # DEFINE BSPM OPERATING POINT | ||
| ######################################################### | ||
| bp4_op_pt = BSPM_Machine_Oper_Pt( | ||
| Id=0, # I_pu | ||
| Iq=0.95, # I_pu | ||
| Ix=0, # I_pu | ||
| Iy=0.05, # I_pu | ||
| speed=160000, # RPM | ||
| ambient_temp=25, # C | ||
| rotor_temp_rise=55, # K | ||
| ) | ||
|
|
||
| Define and Create ``JMAG_2D_Config`` Object | ||
| ------------------------------------------- | ||
|
|
||
| For performing simualtion in JMAG, an instance of ``JMAG_2D_Config`` must be provided (For more information, see :doc:`BSPM JMAG 2D FEA Analyzer <bspm_jmag2d_analyzer>`.) | ||
| Users can paste the provided sample pf the JMAG configuration code to instantiate the ``JMAG_2D_Config`` object: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| ######################################################### | ||
| # DEFINE BSPM JMAG SETTINGS | ||
| ######################################################### | ||
| jmag_config = JMAG_2D_Config( | ||
| no_of_rev_1TS=1, | ||
| no_of_rev_2TS=2, | ||
| no_of_steps_per_rev_1TS=36, | ||
| no_of_steps_per_rev_2TS=360, | ||
| mesh_size=2e-3, | ||
| magnet_mesh_size=1e-3, | ||
| airgap_mesh_radial_div=5, | ||
| airgap_mesh_circum_div=720, | ||
| mesh_air_region_scale=1.15, | ||
| only_table_results=False, | ||
| csv_results=(r"Torque;Force;FEMCoilFlux;LineCurrent;TerminalVoltage;JouleLoss;TotalDisplacementAngle;" | ||
| "JouleLoss_IronLoss;IronLoss_IronLoss;HysteresisLoss_IronLoss"), | ||
| del_results_after_calc=False, | ||
| run_folder=os.path.abspath("") + "/run_data/", | ||
| jmag_csv_folder=os.path.abspath("") + "/run_data/JMAG_csv/", | ||
| max_nonlinear_iterations=50, | ||
| multiple_cpus=True, | ||
| num_cpus=4, | ||
| jmag_scheduler=False, | ||
| jmag_visible=True, | ||
| ) | ||
|
|
||
| .. note:: | ||
|
|
||
| The step and mesh size could significantly affect the results. The user should consider making these values to be more fine. | ||
|
|
||
| Define Problem and Analyzer Object | ||
| ------------------------------------ | ||
|
|
||
| Use the following code to create the problem and analyzer object: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| ######################################################### | ||
| # DEFINE BSPM MACHINE CONSTANTS PROBLEM | ||
| ######################################################### | ||
| problem = bmc.BSPMMachineConstantProblem(bp4,bp4_op_pt) | ||
|
|
||
| ######################################################### | ||
| # DEFINE BSPM MACHINE CONSTANTS ANALYZER | ||
| ######################################################### | ||
| analyzer = bmc.BSPMMachineConstantAnalyzer(jmag_config) | ||
|
|
||
|
|
||
| Output to User | ||
| ********************************** | ||
|
|
||
| The attributes of the results class can be summarized in the table below: | ||
|
|
||
| .. csv-table:: Results of BSPM machine constants analyzer | ||
| :file: result_bspm_mach_constants.csv | ||
| :widths: 30, 70, 30 | ||
| :header-rows: 1 | ||
|
|
||
| Use the following code to run the example analysis: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| ######################################################### | ||
| # SOLVE BSPM MACHINE CONSTANTS PROBLEM | ||
| ######################################################### | ||
| result = analyzer.analyze(problem) | ||
| print(result.Kf) | ||
| print(result.Kt) | ||
| print(result.Kdelta) | ||
| print(result.Kphi) | ||
wchan29 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .. note:: | ||
|
|
||
| The user can install the ``tqdm`` library for a visual progress bar on your terminal when the simulations are running. | ||
|
|
||
| .. note:: | ||
|
|
||
| Depending on the number of evaluation steps specified, a full analysis could take upwards of **one to two hours** to complete. | ||
|
|
||
| Running the example case returns the following: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| 1.8019710307171688 | ||
| 0.0203730830815381 | ||
| 6935.763575553156 | ||
| 0.00456017028983404 | ||
|
|
||
| The results indicate that the example BSPM machine design has a suspension force constant of :math:`k_f = 1.802\; [\frac{N}{A}]`, a torque constant of | ||
| :math:`k_t = 0.0204 \; [\frac{Nm}{A_{pk}}]`, a displacement stiffness constant of :math:`k_\delta = 6935.76\; [\frac{N}{m}]`, and back-EMF constant of | ||
| :math:`k_\phi = 0.00456\; [\frac{V_{rms}}{rad/s}]`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
docs/source/EM_analyzers/input_bspm_mach_constants_analyzer.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Arguments, Type, Description | ||
| config, ``JMAG_2D_Config``," object of type JMAG_2D_Config describing time step and mesh setting, etc." | ||
| Kf_Kt_step, int (default - *10*), number of steps for evaluating suspension force and torque constant | ||
| Kdelta_coords, list (default - *see below*), list of coordinate points [x y] in mm | ||
| Kphi_step, int (default - *10*), number of steps for evaluating back-EMF constant |
7 changes: 7 additions & 0 deletions
7
docs/source/EM_analyzers/input_bspm_mach_constants_problem.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Arguments, Type, Description | ||
| machine, ``BSPM_machine``, instance of ``BSPM_machine`` | ||
| operating_point,``BSPM_Machine_Oper_Pt``, instance of ``BSPM_Machine_Oper_Pt`` | ||
| solve_Kf,bool (default - *True*), boolean input to check whether to solve Kf value or not | ||
| solve_Kt,bool (default - *True*),boolean input to check whether to solve Kt value or not | ||
| solve_Kphi,bool (default - *True*),boolean input to check whether to solve Kphi value or not | ||
| solve_Kdelta,bool (default - *True*),boolean input to check whether to solve Kdelta value or not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Attribute,Description,Units | ||
| Kf, Suspension force constant, N/A | ||
| Kt, Torque constant, N-m/A_pk | ||
| Kdelta, Displacement stiffness constant, N/m | ||
| Kphi, Back-EMF constant , V_rms/rad/s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.