Capacity of Cathode/Anode

Theoretical capacity of the material is calculated when it transfers one gram of ions. Ionic transfer of Lithium is measured in lithium batteries as so for their counterparts like Na, K  or Mg.

Lithium is said to be having theoretical capacity or specific capacity of 3842 mAh/g. This value sounds exciting as well as controversy since for this much energy the whole lithium has to move, but in principle only a part of lithium which placed at anode side moves. So how is it calculated and for other materials.
In general, theoretical capacity of a material is given by: 
C=nF (Coulomb)
where n is the number of electron transferred and F is the Faraday constant. This value has to be divided by molecular weight (MW) of the material for the theoretical specific capacity
 Csp=nF/MW (Coulomb/g)
Since 1 Coulomb = 1Amp-Sec = 1000 mA * h/3600
Csp=  1000/3600. nF / MW (mAh/g)

One Li+ ion is equivalent to one electron transfer, same is for the case of Na and potassium ion but for Mg it is two electrons

Note: Theoretical Csp doesn't depend on either operating voltage or current

 Online calculator for theoretical Capacity

From Galvanostatic Technique
Battery Capacity Determination is done in galvanostatic mode with a constant current and a defined voltage limits, generally the battery cycler gives the final value.

It can be calculated from constant current or galvanostatic technique as
Capacity =i (mA) . t (h). 1/m ΔV

For Discharge/Charge capacity i= Charge/Discharge current and t= time for charging/discharge respectively, while m is the mass of the active material and ΔV is the potential window

Note: The capacity is always high for slow charging rate and decreases with increase in charging current due to insufficient intercalation, while most of the result is due to polarization of the battery

For variable current the the capacity can be calculated by integrating current with respect to time or it is equal to the are under the curve of i vs t.
Capacity = i(t)dt . 1/m ΔV

From CV Curve
When cyclic voltammetry (CV) done at slow rate provides information about thermodynamics of redox processes and kinetics on reactions occurred on battery electrodes and electrode-electrolyte interface.  CV provides information on redox processes, heterogeneous electron transfer reactions and adsorption processes. It offers a rapid location of redox potentials of the electroactive species.

From a CV vurve
Capacity = i(v)dv . 1/2m𝜇 ΔV
 where 𝜇 is the scan rate(mV/s), graphically the value of i(v)dv is equal to the area under CV curve, m is the mass of active material (g) and ΔV is the potential window

Specific Energy Density
It is equal to the product of the maximum capacity to the nominal capacity. Nominal capacity is generally given by the industry, when we don't have this value then we can take the potential of the battery when it is discharged to 50% of its maximum capacity (i.e, mid-point potential)
For a cell
Specific Energy Density= nominal voltage (V) x capacity rating(Ah) /cell weight(kg)      (Wh/kg)

Note: In scientific literature, generally the specific capacity or energy density is calculated for the electrode, i.e., only the weight of the active material is considered for reporting. In reality other materials, electrodes and other components are involved in making of  cell but they are not presented since their focus is only the active material. On the other side, the industries report values considering the weight of the cathode material used in the cell, well don't imagine that all of the material will be participating in oxidation/reduction.Thus the measured capacity will be definitely less than that of capacity printed on the cell.