Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions docs/Components/Powertrain/SimpleMotor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Simple Motor

Simple Motor class is based on the class called "attatched component", and written over the Motor class. For the fact that it is an attatched component, it is needed to set a parent for it, and just like on attached component, all information from the parent will be taken in count on the children methods.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...based on the Motor class, which inherits from the AttachedComponent class, ...


Besides that the class needs some inputs values from the user, such as:
* static_thrust
* linear_coefficient
* distance_origin_to_propeller

## *Thrust Center* _method_:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use the same name as the method (thrust_center).


It's a property that returns a Vector2 with the values of the points where the thrust is applied.

As it is a Simple Motor, by default the force is applied on x in the distance from the origin to the propeller and in y, in 0 as it's seen in the example below:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is a simplified model of a motor, by default the force is applied on the motor axis (y = 0), on a given distance (distance_origin_to_propeller) over the horizontal X-axis, as it's seen in the example below:


```python
motor = SimpleMotor(
name='attached_component',
mass=1.4,
relative_position=Vector2(-0.4, 0.1),
relative_angle=math.radians(0),
static_thrust = 78,
linear_coefficient = -1,
distance_origin_to_propeller = 0.3
)

env = Ambient()
plane = FreeBody(
name='freebody',
type='generic_freebody',
mass=23.4,
position_cg=Vector2(-0.2, 0.02),
pitch_rot_inertia=5.2,
ambient=env,
)

motor.set_parent(plane)

print(motor.thrust_center)
>>> Vector2(0.3, 0)
```
##*Get Thrust* method:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_thrust


This methods is responsible for returning the magnitude value of the given thrust. To make the calculation, the method calls the function get_axial_thrust_from_linear_model, that takes into consideration the motor inputs, the environment variables, and the given velocity of the aircraft rotated to the axial velocity, considering the angle of attack.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns the magnitude of the thrust and the point where it is applied.

...and the given velocity of the aircraft rotated to the axial velocity, considering the angle of attack. can be better described this way:

...and the component of the aircraft velocity aligned with the motor axis.


The method returns to vectors, one with the thrust magnitude and the other one with the thrust_center, that was calculated on the method before.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be merged with the first phrase.


```python

thrust_magnitude, thrust_center = motor.get_thrust()

print(thrust_magnitude)
>>> Vector2(82.269378, 0)
print(thrust_center)
>>> Vector2(0.3, 0)
```

55 changes: 55 additions & 0 deletions tests/Components/Powertrain/test_SimpleMotor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import attr
from vec import Vector2
from adr.World import Ambient
from adr.Components import FreeBody
from adr.Components.Powertrain import SimpleMotor
from adr.Methods.Powertrain.thrust_equations import get_axial_thrust_from_linear_model
import numpy.testing as npt
import math
import pytest

@pytest.fixture
def motor():
motor = SimpleMotor(
name='attached_component',
mass=1.4,
relative_position=Vector2(-0.4, 0.1),
relative_angle=math.radians(0),
static_thrust = 78,
linear_coefficient = -1,
distance_origin_to_propeller = 0.3
)
return motor

@pytest.fixture
def plane():
env = Ambient()
plane = FreeBody(
name='freebody',
type='generic_freebody',
mass=23.4,
position_cg=Vector2(-0.2, 0.02),
pitch_rot_inertia=5.2,
ambient=env,
)
return plane

def test_thrust_center(motor, plane):

motor.set_parent(plane)

check_thrust_center = Vector2(0.3, 0)
Comment on lines +37 to +41
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excess of blank lines


assert(motor.thrust_center == check_thrust_center)

def test_get_thrust(motor, plane):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this blank line

motor.set_parent(plane)
x,y = motor.get_thrust()

check_thrust_center = Vector2(0.3, 0)
check_thrust = Vector2(82.269378, 0)

npt.assert_array_almost_equal(x, check_thrust)
npt.assert_array_almost_equal(y, check_thrust_center)
Comment on lines +48 to +54
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x and y are bad names, not recognizable. You could use thrust_center and thrust, as you use right after.