Skip to content

Commit

Permalink
Merge fbd7259 into 3fa4b66
Browse files Browse the repository at this point in the history
  • Loading branch information
mclarke2 committed May 12, 2022
2 parents 3fa4b66 + fbd7259 commit 89afaa8
Showing 1 changed file with 9 additions and 7 deletions.
Expand Up @@ -70,15 +70,17 @@ def initialize_conditions(segment):
if v0 is None:
v0 = segment.state.initials.conditions.frames.inertial.velocity_vector[-1,:]
segment.velocity_vector = v0


elif len(np.shape(v0)) == 0:
v0 = np.array([v0, 0, 0])

# discretize on altitude
v0_mag = np.linalg.norm(v0)
alt = t_nondim * (altf-alt0) + alt0
ground_distance = abs(altf-alt0)/np.tan(climb_angle)
ground_distance = (altf-alt0)/np.tan(climb_angle)
true_distance = np.sqrt((altf-alt0)**2 + ground_distance**2)
t_initial = conditions.frames.inertial.time[0,0]
elapsed_time = (-v0_mag + np.sqrt(v0_mag**2 + 2*ax*true_distance))/(ax)
t_initial = conditions.frames.inertial.time[0,0]
elapsed_time = (-v0_mag + np.sqrt(v0_mag**2 + 2*ax*true_distance))/(ax)
vf_mag = v0_mag + ax*(elapsed_time)

# dimensionalize time
Expand All @@ -92,15 +94,15 @@ def initialize_conditions(segment):
vz = t_nondim * V * np.sin(climb_angle) + v0[2] * np.sin(climb_angle)

# set the body angle
body_angle =time*(Tf-T0)/(t_final-t_initial) + T0
body_angle = time*(Tf-T0)/(t_final-t_initial) + T0
segment.state.conditions.frames.body.inertial_rotations[:,1] = body_angle[:,0]

# pack
segment.state.conditions.freestream.altitude[:,0] = alt[:,0]
segment.state.conditions.freestream.altitude[:,0] = alt[:,0]
segment.state.conditions.frames.inertial.position_vector[:,2] = -alt[:,0] # z points down
segment.state.conditions.frames.inertial.velocity_vector[:,0] = vx[:,0]
segment.state.conditions.frames.inertial.velocity_vector[:,2] = -vz[:,0]
segment.state.conditions.frames.inertial.time[:,0] = time[:,0]
segment.state.conditions.frames.inertial.time[:,0] = time[:,0]

# ----------------------------------------------------------------------
# Residual Total Forces
Expand Down

0 comments on commit 89afaa8

Please sign in to comment.