import numpy as np
def update_weights_sprayer(segment,state): # unpack conditions = state.conditions m0 = conditions.weights.total_mass[0,0] m_empty = segment.analyses.weights.mass_properties.operating_empty mdot_fuel = conditions.weights.vehicle_mass_rate I = state.numerics.time.integrate g = conditions.freestream.gravity # Add in the sprayer mass rate sprayer = segment.sprayer_rate mdot = mdot_fuel + sprayer
# calculate m = m0 + np.dot(I, -mdot )
# weight W = m*g
# pack conditions.weights.total_mass[1:,0] = m[1:,0] # don't mess with m0 conditions.frames.inertial.gravity_force_vector[:,2] = W[:,0]
return
# ------------------------------------------------------------------ # Cruise Segment: constant speed, constant altitude # ------------------------------------------------------------------
segment = Segments.Cruise.Constant_Speed_Constant_Altitude(base_segment) segment.tag = "cruise"
segment.analyses.extend( analyses.cruise )
segment.air_speed = 230.412 * Units['m/s'] segment.distance = (3933.65 + 770 - 92.6) * Units.km segment.altitude = 10.668 * Units.km segment.process.iterate.conditions.weights = update_weights_sprayer segment.sprayer_rate = 5. * Units['kg/s']
# add to mission mission.append_segment(segment)
import numpy as np
def update_weights_sprayer(segment,state): # unpack conditions = state.conditions m0 = conditions.weights.total_mass[0,0] m_empty = segment.analyses.weights.mass_properties.operating_empty mdot_fuel = conditions.weights.vehicle_mass_rate I = state.numerics.time.integrate g = conditions.freestream.gravity # Add in the sprayer mass rate
sprayer = segment.sprayer_rate * state.ones_row(1) # Integrate the masses fuel = np.dot(I, mdot_fuel ) spray = np.dot(I, sprayer )
# calculate m = m0 - fuel - spray
# weight W = m*g
# pack conditions.weights.total_mass[1:,0] = m[1:,0] # don't mess with m0 conditions.frames.inertial.gravity_force_vector[:,2] = W[:,0]
# pack sprayer mass and fuel burn conditions.weights.fuel_burn = fuel conditions.weights.spray = spray
return