diff --git a/kspalculator/design.py b/kspalculator/design.py index 1692578..8bd8fde 100644 --- a/kspalculator/design.py +++ b/kspalculator/design.py @@ -319,78 +319,67 @@ def determine_features(self, designs, preferredsize, bestgimbal, prefergenerator self.features.add(Features.radial_size) -def create_single_lfe_design(payload, pressure, dv, acc, eng): - design = Design(payload, eng, 1, eng.size, parts.FuelTypes.LiquidFuel) - lf = physics.lf_needed_fuel(dv, physics.engine_isp(eng, pressure), design.get_mass(), 1/8) +def create_lf_design(payload, pressure, dv, acc, eng, + size=None, count=1, fueltype=parts.FuelTypes.LiquidFuel, tank=None): + """Creates a simple non-SFB design with given parameters + + :type eng: parts.Engine + :type size: parts.RadialSize + :type fueltype: parts.FuelTypes + :type tank: parts.SpecialFuelTank + """ + if size is None: + size = eng.size + design = Design(payload, eng, count, size, fueltype) + if fueltype is parts.FuelTypes.LiquidFuel: + f_e = 1 / 8 + elif fueltype is parts.FuelTypes.AtomicFuel: + f_e = parts.AtomicTank_f_e + else: + f_e = tank.f_e + lf = physics.lf_needed_fuel(dv, physics.engine_isp(eng, pressure), design.get_mass(), f_e) if lf is None: return None - design.add_conventional_tanks(9 / 8 * lf) + if fueltype is parts.FuelTypes.LiquidFuel or fueltype is parts.FuelTypes.AtomicFuel: + design.add_conventional_tanks((1 + f_e) * lf) + else: + design.add_special_tanks((1 + f_e) * lf, tank) design.calculate_performance(dv, pressure) if not design.has_enough_acceleration(acc): return None return design +def create_single_lfe_design(payload, pressure, dv, acc, eng): + return create_lf_design(payload, pressure, dv, acc, eng) + + def create_radial_lfe_design(payload, pressure, dv, acc, eng, size, count): - design = Design(payload, eng, count, size, parts.FuelTypes.LiquidFuel) - lf = physics.lf_needed_fuel(dv, physics.engine_isp(eng, pressure), design.get_mass(), 1/8) - if lf is None: - return None - design.add_conventional_tanks(9 / 8 * lf) - design.calculate_performance(dv, pressure) - if not design.has_enough_acceleration(acc): - return None - return design + return create_lf_design(payload, pressure, dv, acc, eng, size=size, count=count) def create_atomic_design(payload, pressure, dv, acc): - design = Design(payload, parts.AtomicRocketMotor, 1, parts.RadialSize.Small, parts.FuelTypes.AtomicFuel) - f_e = parts.AtomicTank_f_e - af = physics.lf_needed_fuel(dv, physics.engine_isp(parts.AtomicRocketMotor, pressure), - design.get_mass(), f_e) - if af is None: - return None - design.add_conventional_tanks((1 + f_e) * af) - design.calculate_performance(dv, pressure) - if not design.has_enough_acceleration(acc): - return None - return design + return create_lf_design(payload, pressure, dv, acc, parts.AtomicRocketMotor, + count=1, fueltype=parts.FuelTypes.AtomicFuel) def create_xenon_design(payload, pressure, dv, acc, tank): size = tank.size if tank.size is not parts.RadialSize.RadiallyMounted else parts.RadialSize.Tiny - design = Design(payload, parts.ElectricPropulsionSystem, 1, size, parts.FuelTypes.Xenon) - f_e = tank.f_e - xf = physics.lf_needed_fuel(dv, physics.engine_isp(parts.ElectricPropulsionSystem, pressure), - design.get_mass(), f_e) - if xf is None: - return None - design.add_special_tanks((1 + f_e) * xf, tank) - design.calculate_performance(dv, pressure) - if not design.has_enough_acceleration(acc): - return None - return design + return create_lf_design(payload, pressure, dv, acc, parts.ElectricPropulsionSystem, + size=size, fueltype=parts.FuelTypes.Xenon, tank=tank) def create_monopropellant_design(payload, pressure, dv, acc, tank, count): - design = Design(payload, parts.MonoPropellantEngine, count, tank.size, parts.FuelTypes.Monopropellant) - f_e = tank.f_e - mp = physics.lf_needed_fuel(dv, physics.engine_isp(parts.MonoPropellantEngine, pressure), - design.get_mass(), f_e) - if mp is None: - return None - design.add_special_tanks((1 + f_e) * mp, tank) - design.calculate_performance(dv, pressure) - if not design.has_enough_acceleration(acc): - return None - return design + return create_lf_design(payload, pressure, dv, acc, parts.MonoPropellantEngine, + size=tank.size, count=count, fueltype=parts.FuelTypes.Monopropellant, tank=tank) -def create_single_lfe_sfb_design(payload, pressure, dv, acc, eng, eng_F_percentage, sfb, sfbcount): - design = Design(payload, eng, 1, eng.size, parts.FuelTypes.LiquidFuel) +def create_sfb_design(payload, pressure, dv, acc, eng, eng_F_percentage, size, count, sfb, sfbcount): + """Create LiquidFuel + SFB design with given parameters""" + design = Design(payload, eng, count, size, parts.FuelTypes.LiquidFuel) design.add_sfb(sfb, sfbcount) # lpsr = Fl * I_sps / Fs / I_spl - lpsr = eng.F_vac * sfb.isp_vac / sfbcount / sfb.F_vac / eng.isp_vac + lpsr = count * eng.F_vac * sfb.isp_vac / sfbcount / sfb.F_vac / eng.isp_vac design.eng_F_percentage = eng_F_percentage lf = physics.sflf_concurrent_needed_fuel(dv, physics.engine_isp(eng, pressure), physics.engine_isp(sfb, pressure), @@ -407,25 +396,13 @@ def create_single_lfe_sfb_design(payload, pressure, dv, acc, eng, eng_F_percenta return design +def create_single_lfe_sfb_design(payload, pressure, dv, acc, eng, eng_F_percentage, sfb, sfbcount): + return create_sfb_design(payload, pressure, dv, acc, eng, eng_F_percentage, eng.size, 1, sfb, sfbcount) + + def create_radial_lfe_sfb_design(payload, pressure, dv, acc, eng, eng_F_percentage, size, count, sfb, sfbcount): - design = Design(payload, eng, count, size, parts.FuelTypes.LiquidFuel) - design.add_sfb(sfb, sfbcount) - # lpsr = Fl * I_sps / Fs / I_spl - lpsr = count * eng.F_vac * sfb.isp_vac / sfbcount / sfb.F_vac / eng.isp_vac - design.eng_F_percentage = eng_F_percentage - lf = physics.sflf_concurrent_needed_fuel(dv, physics.engine_isp(eng, pressure), - physics.engine_isp(sfb, pressure), - design.get_mass() - design.get_sfbmountmass() - sfbcount*sfb.m_full, - design.get_sfbmountmass(), sfbcount*sfb.m_full, sfbcount*sfb.m_empty, lpsr*eng_F_percentage) - if lf is None: - return None - design.add_conventional_tanks(9 / 8 * lf) - design.calculate_performance(dv, pressure) - if not design.has_enough_acceleration(acc): - return None - if sfbcount != 1: - design.notes.append("Set liquid fuel engine thrust to {:.0%} while SFB are burning".format(eng_F_percentage)) - return design + return create_sfb_design(payload, pressure, dv, acc, eng, eng_F_percentage, size, count, sfb, sfbcount) + def find_designs(payload, pressure, dv, min_acceleration, preferredsize = None, bestgimbal = 0, sfballowed = False, prefergenerators = False, diff --git a/kspalculator/parts.py b/kspalculator/parts.py index 20cee1e..fb6702b 100644 --- a/kspalculator/parts.py +++ b/kspalculator/parts.py @@ -27,43 +27,43 @@ class RadialSize(Enum): # 2 -> ok with LT-2 landing struts (Poodle, Reliant, Swivel) # 3 -> all others... -LiquidFuelEngine = namedtuple('LiquidFuelEngine', ['size', 'name', 'cost', 'm', 'isp_atm', +Engine = namedtuple('Engine', ['size', 'name', 'cost', 'm', 'isp_atm', 'isp_vac', 'F_vac', 'tvc', 'level', 'electricity', 'length']) LiquidFuelEngines = [ - LiquidFuelEngine(RadialSize.RadiallyMounted, 'LV-1R Spider', 120, 20, 260, 290, 2000, 8, + Engine(RadialSize.RadiallyMounted, 'LV-1R Spider', 120, 20, 260, 290, 2000, 8, ResearchNode.PrecisionPropulsion, 0, 0), - LiquidFuelEngine(RadialSize.RadiallyMounted, '24-77 Twitch', 400, 90, 250, 290, 16000, 8, + Engine(RadialSize.RadiallyMounted, '24-77 Twitch', 400, 90, 250, 290, 16000, 8, ResearchNode.PrecisionPropulsion, 0, 0), - LiquidFuelEngine(RadialSize.RadiallyMounted, 'Mk-55 Thud', 820, 900, 275, 305, 120000, 8, + Engine(RadialSize.RadiallyMounted, 'Mk-55 Thud', 820, 900, 275, 305, 120000, 8, ResearchNode.AdvancedRocketry, 0, 0), - LiquidFuelEngine(RadialSize.Tiny, 'LV-1 Ant', 110, 20, 80, 315, 2000, 0, + Engine(RadialSize.Tiny, 'LV-1 Ant', 110, 20, 80, 315, 2000, 0, ResearchNode.PropulsionSystems, 0, 0), - LiquidFuelEngine(RadialSize.Tiny, '48-7S Spark', 200, 100, 270, 300, 18000, 3, + Engine(RadialSize.Tiny, '48-7S Spark', 200, 100, 270, 300, 18000, 3, ResearchNode.PropulsionSystems, 0, 0), - LiquidFuelEngine(RadialSize.Small, 'LV-909 Terrier', 390, 500, 85, 345, 60000, 4, + Engine(RadialSize.Small, 'LV-909 Terrier', 390, 500, 85, 345, 60000, 4, ResearchNode.AdvancedRocketry, 0, 0), - LiquidFuelEngine(RadialSize.Small, 'LV-T30 Reliant', 1100, 1250, 280, 300, 215000, 0, + Engine(RadialSize.Small, 'LV-T30 Reliant', 1100, 1250, 280, 300, 215000, 0, ResearchNode.GeneralRocketry, 1, 2), - LiquidFuelEngine(RadialSize.Small, 'LV-T45 Swivel', 1200, 1500, 270, 320, 200000, 3, + Engine(RadialSize.Small, 'LV-T45 Swivel', 1200, 1500, 270, 320, 200000, 3, ResearchNode.BasicRocketry, 1, 2), - LiquidFuelEngine(RadialSize.Small, 'S3 KS-25 Vector',18000,4000, 295, 315, 1000000, 10.5, + Engine(RadialSize.Small, 'S3 KS-25 Vector',18000,4000, 295, 315, 1000000, 10.5, ResearchNode.VeryHeavyRocketry, 1, 3), - LiquidFuelEngine(RadialSize.Small, 'CR7 RAPIER', 6000, 2000, 275, 305, 180000, 3, + Engine(RadialSize.Small, 'CR7 RAPIER', 6000, 2000, 275, 305, 180000, 3, ResearchNode.AerospaceTech, 0, 3), - LiquidFuelEngine(RadialSize.Small, 'T-1 Dart', 3850, 1000, 290, 340, 180000, 0, + Engine(RadialSize.Small, 'T-1 Dart', 3850, 1000, 290, 340, 180000, 0, ResearchNode.HypersonicFlight, 1, 1), - LiquidFuelEngine(RadialSize.Large, 'RE-L10 Poodle', 1300, 1750, 90, 350, 250000, 4.5, + Engine(RadialSize.Large, 'RE-L10 Poodle', 1300, 1750, 90, 350, 250000, 4.5, ResearchNode.HeavyRocketry, 1, 2), - LiquidFuelEngine(RadialSize.Large, 'RE-I5 Skipper', 5300, 3000, 280, 320, 650000, 2, + Engine(RadialSize.Large, 'RE-I5 Skipper', 5300, 3000, 280, 320, 650000, 2, ResearchNode.HeavyRocketry, 1, 3), - LiquidFuelEngine(RadialSize.Large, 'RE-M3 Mainsail', 13000,6000, 285, 310, 1500000,2, + Engine(RadialSize.Large, 'RE-M3 Mainsail', 13000,6000, 285, 310, 1500000,2, ResearchNode.HeavierRocketry, 1, 3), - LiquidFuelEngine(RadialSize.Large, 'LFB Twin-Boar', 11250,6500, 280, 300, 2000000, 1.5, + Engine(RadialSize.Large, 'LFB Twin-Boar', 11250,6500, 280, 300, 2000000, 1.5, ResearchNode.HeavierRocketry, 0, 3), - LiquidFuelEngine(RadialSize.ExtraLarge, 'KR-2L+ Rhino', 25000,9000, 255, 340, 2000000, 4, + Engine(RadialSize.ExtraLarge, 'KR-2L+ Rhino', 25000,9000, 255, 340, 2000000, 4, ResearchNode.VeryHeavyRocketry, 1, 3), - LiquidFuelEngine(RadialSize.ExtraLarge, 'KS-25x4 Mammoth', 39000,15000, 295, 315, 4000000, 2, + Engine(RadialSize.ExtraLarge, 'KS-25x4 Mammoth', 39000,15000, 295, 315, 4000000, 2, ResearchNode.VeryHeavyRocketry, 1, 3) ] # Twin-Boar is the engine as listed above, with forced addition of the 36 ton large liquid fuel @@ -103,16 +103,14 @@ def __init__(self, pname, unitmass): self.pname = pname self.unitmass = unitmass -SpecialEngine = namedtuple('SpecialEngine', ['size', 'name', 'cost', 'm', 'isp_atm', 'isp_vac', - 'F_vac', 'tvc', 'level', 'electricity', 'length']) SpecialFuelTank = namedtuple('SpecialFuelTank', ['name', 'size', 'cost', 'm_full', 'f_e', 'level']) -AtomicRocketMotor = SpecialEngine(RadialSize.Small, 'LV-N Nerv Atomic Rocket Motor', 10000, 3000, +AtomicRocketMotor = Engine(RadialSize.Small, 'LV-N Nerv Atomic Rocket Motor', 10000, 3000, 185, 800, 60000, 0, ResearchNode.NuclearPropulsion, 1, 3) AtomicTankFactor = 23/45 # Mass of full atomic fuel tank / Mass of full liquid fuel tank AtomicTank_f_e = 5/18 -ElectricPropulsionSystem = SpecialEngine(RadialSize.Tiny, 'IX-6315 Dawn Electric Propulsion System', +ElectricPropulsionSystem = Engine(RadialSize.Tiny, 'IX-6315 Dawn Electric Propulsion System', 8000, 250, 100, 4200, 2000, 0, ResearchNode.IonPropulsion, 0, 0) XenonTanks = [ SpecialFuelTank('PB-X150', RadialSize.Tiny, 3600, 125, 11/14, ResearchNode.IonPropulsion), @@ -120,7 +118,7 @@ def __init__(self, pname, unitmass): SpecialFuelTank('PB-X50R', RadialSize.RadiallyMounted, 2200, 71.4, 157/200, ResearchNode.IonPropulsion) ] MonoPropellantEngine = \ - SpecialEngine(RadialSize.RadiallyMounted, 'O-10 Puff MonoPropellant Fuel Engine', + Engine(RadialSize.RadiallyMounted, 'O-10 Puff MonoPropellant Fuel Engine', 150, 90, 120, 250, 20000, 0, ResearchNode.PrecisionPropulsion, 0, 0) MonoPropellantTanks = [ SpecialFuelTank('FL-R10', RadialSize.Tiny, 200, 370, 5/32, ResearchNode.AdvancedFuelSystems),