Given where Earth is at departure and where Mars will be at arrival, a Lambert problem gives the orbit connecting them in a fixed time of flight.
import pykep as pk
from lib.orbits import lambert_transfer
t = lambert_transfer("earth", "mars", dep_mjd2000=10000, arr_mjd2000=10300)
print(f"time of flight : {t['tof']/86400:.0f} days")
print(f"departure v : {t['v1']} m/s")
time of flight : 300 days
departure v : [ 14997.23930247 -27871.52664242 -813.60131097] m/s
from lib.retro_plot import retro_axes, ORANGE, RED, TEAL, YELLOW
import pykep as pk
AU = pk.AU
p = t["path"] / AU
fig, ax = retro_axes("Lambert transfer", "x [AU]", "y [AU]", equal=True)
ax.plot(p[:, 0], p[:, 1], label="transfer")
ax.scatter(0, 0, color=YELLOW, s=120, label="Sun", zorder=5)
ax.scatter(*(t["r1"][:2] / AU), color=TEAL, label="Earth (dep)", zorder=5)
ax.scatter(*(t["r2"][:2] / AU), color=RED, label="Mars (arr)", zorder=5)
ax.legend()
fig