def calc_sigma_general(wfh, wfe, N_state, N_statec, model, Ntotal2d, j,
    Well_boundary):
    """This function calculates `net' areal charge density
    n-type dopants lead to -ve charge representing electrons, and additionally 
    +ve ionised donors."""
    sigma = model.dop[Well_boundary[j - 1, 1]:Well_boundary[j + 1, 0]
        ] * model.dx
    if Ntotal2d > 0:
        for j in range(0, model.subnumber_e, 1):
            sigma -= N_statec[j] * wfe[j] ** 2
    else:
        for i in range(0, model.subnumber_h, 1):
            sigma += N_state[i] * wfh[i] ** 2
    return sigma
