Reverse engineering PVPoke's modified stat calculations

I use PVPoke to simulate battles for GL & UL, and while a great resource, only processes one Mon at a time. I have a spreadsheet of the base stats for all Pokemon which is what PVPoke uses to start, and then modifies the stats based upon IVs and Level. This results in a Stamina number that is used in a battle simulation and is depleted until one Mon faints.

I’m looking for the formula that PVPoke users to calculate these modified stats based upon the base stats. Anyone have this formula or formulas handy?

I believe everything you need is here :
You’ll need to find the multipliers for level 40.5-51 somewhere else though.
If I remember correctly some mons are nerfed if their lvl 40 max cp surpass 4000 but I can’t remember how much (something like a 0.91 multiplication in all their stats but I’m not sure).