Skip to content
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

BUG: Motor method 'export_eng' for liquid motors bug fix. (solves #473) #559

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Changes from 1 commit
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
45 changes: 34 additions & 11 deletions rocketpy/motors/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,18 +1014,41 @@
# Open file
file = open(file_name, "w")

# Write first line
file.write(
motor_name
+ " {:3.1f} {:3.1f} 0 {:2.3} {:2.3} RocketPy\n".format(
2000 * self.grain_outer_radius,
1000
* self.grain_number
* (self.grain_initial_height + self.grain_separation),
self.propellant_initial_mass,
self.propellant_initial_mass,
if (
hasattr(self, "grain_outer_radius")
and hasattr(self, "grain_number")
and hasattr(self, "grain_initial_height")
and hasattr(self, "grain_separation")
):
# Write first line for motors with grains
file.write(
motor_name
+ " {:3.1f} {:3.1f} 0 {:2.3} {:2.3} RocketPy\n".format(
2000 * self.grain_outer_radius,
1000
* self.grain_number
* (self.grain_initial_height + self.grain_separation),
self.propellant_initial_mass,
self.propellant_initial_mass,
)
)

else:
# Warn the user that the motor doesn't have at least one grain attribute
warnings.warn(

Check warning on line 1038 in rocketpy/motors/motor.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/motors/motor.py#L1038

Added line #L1038 was not covered by tests
"The motor object doesn't have some grain-related attributes. Using zeros to write to file."
)

# Write first line for motors without grain attributes
# The zeros are here because the first two placeholders
# are grain-related attributes.
file.write(

Check warning on line 1045 in rocketpy/motors/motor.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/motors/motor.py#L1045

Added line #L1045 was not covered by tests
motor_name
+ " 0 0 0 {:2.3} {:2.3} RocketPy\n".format(
self.propellant_initial_mass,
self.propellant_initial_mass,
)
)
)

# Write thrust curve data points
for time, thrust in self.thrust.source[1:-1, :]:
Expand Down
Loading