reformulated a lot of the previous files, added supporting functions to enable sim to run and all math to be done properly