How do I render just one frame of a smoke animation using Blender Python API I have a smoke animation that is 50 frames long and I want to render only the last frame as an image. 

I tried:

bpy.context.scene.frame_set(50)
bpy.ops.render.render(write_still=True)


But this doesn't render the fiftieth frame of the animation properly. The smoke animation doesn't update to what it should look like at frame 50 and instead stays at its frame 0 state
I managed to solve this by:

hbpy.data.scenes['Scene'].render.filepath = "FilePath"
frame_start = 1
frame_end = 50
bpy.context.scene.frame_set(frame_start)
for frame in range(frame_start, frame_end+1):
    bpy.context.scene.frame_set(frame)
    if frame==frame_end:
        bpy.ops.render.render(write_still=True)