<commit_before>module sbzequations
    use double
    use environment
    use brillouin
    use scsolve
    use scsystem
    implicit none
contains
    ! --- D equation ---
    function sbzEqD(env)
        type(Environ), intent(in) :: env
        type(SelfConsistentEq) :: sbzEqD
        ! (Mostly) arbitrary bounds (should D be positive?).
        sbzEqD%argMin = 1e-9
        sbzEqD%argMax = 10.0 * abs(env%t)
        sbzEqD%setArg => setD
        sbzEqD%absError => absErrorD
    end function

    function absErrorD(env)
        type(Environ), intent(in) :: env
        real(kind=DP) :: absErrorD, rhs
        rhs = BrilSum(env, sumFuncD) / (env%zoneLength ** 3)
        absErrorD = env%D - rhs
    end function

    function sumFuncD(env, k)<commit_msg>add self-consistent system constructors in sbzequations<commit_after>module sbzequations
    use double
    use environment
    use brillouin
    use scsolve
    use scsystem
    implicit none
contains
    ! --- Full self-consistent system ---
    function sbzSystem(env, tolerances)
        type(Environ), intent(in) :: env
        real(kind=DP), dimension(:), allocatable :: tolerances
        type(SelfConsistentEq), dimension(:), allocatable :: equations
        type(SelfConsistentSystem) :: sbzSystem
        allocate(equations(1:8))
        equations(1) = sbzEqMuF(env)
        equations(2) = sbzEqMuB(env)
        equations(3) = sbzEqD(env)
        equations(4) = sbzEqDc(env)
        equations(5) = sbzEqB(env)
        equations(6) = sbzEqBc(env)
        equations(7) = sbzEqA(env)
        equations(8) = sbzEqAc(env)
        sbzSystem%tolerances = tolerances
        sbzSystem%equations = equations
    end function

    ! --- Self-consistent system without c-direction equations ---
    function sbzSystemNoC(env, tolerances)
        type(Environ), intent(in) :: env
        real(kind=DP), dimension(:), allocatable :: tolerances
        type(SelfConsistentEq), dimension(:), allocatable :: equations
        type(SelfConsistentSystem) :: sbzSystemNoC
        allocate(equations(1:5))
        equations(1) = sbzEqMuF(env)
        equations(2) = sbzEqMuB(env)
        equations(3) = sbzEqD(env)
        equations(4) = sbzEqB(env)
        equations(5) = sbzEqA(env)
        sbzSystemNoC%tolerances = tolerances
        sbzSystemNoC%equations = equations
    end function

    ! --- D equation ---
    function sbzEqD(env)
        type(Environ), intent(in) :: env
        type(SelfConsistentEq) :: sbzEqD
        ! (Mostly) arbitrary bounds (should D be positive?).
        sbzEqD%argMin = 1e-9
        sbzEqD%argMax = 10.0 * abs(env%t)
        sbzEqD%setArg => setD
        sbzEqD%absError => absErrorD
    end function

    function absErrorD(env)
        type(Environ), intent(in) :: env
        real(kind=DP) :: absErrorD, rhs
        rhs = BrilSum(env, sumFuncD) / (env%zoneLength ** 3)
        absErrorD = env%D - rhs
    end function

    function sumFuncD(env, k)
{'fraction_non_alphanumeric': 0.10929519918283963, 'fraction_numerical': 0.009874021109976166, 'mean_word_length': 2.5270108043217285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1835999', 'n_tokens_mistral': 967, 'n_tokens_neox': 963, 'n_words': 210}