This is an elastica curve. This GH code shared by Daniel Piker might be helpful:
You can also check out this workshop by Fereshteh Khojastehmehr: