"""Test the species defaults"""

from pyfhiaims.species_defaults.species import SpeciesDefaults

species_content_in = """################################################################################
#
#  FHI-aims code project
#  Volker Blum, Fritz Haber Institute Berlin, 2009
#
#  Suggested "tight" defaults for Si atom (to be pasted into control.in file)
#
#  Revised Jan 04, 2011, following tests (SiC) done by Lydia Nemec:
#     d and g functions of tier 2 now enabled by default.
#
################################################################################

  species        Si
#     global species definitions
    nucleus             14
    mass                28.0855
#
    l_hartree           6
#
    cut_pot             4.0          2.0  1.0
    basis_dep_cutoff    1e-3
#
    radial_base         42 7.0
    radial_multiplier   2
    angular_grids       specified
      division   0.4121   50
      division   0.7665  110
      division   1.0603  194
      division   1.2846  302
      division   1.4125  434
#      division   1.4810  590
#      division   1.5529  770
#      division   1.6284  974
#      division   2.6016 1202
#      outer_grid   974
      outer_grid  434
################################################################################
#
# Optional keywords
#
################################################################################
    cut_atomic_basis           .true.
    plus_u                     2 p 0.5
    plus_u                     3 d 0.25
    cut_core                   infinte 2.0
    innermost_max              5
################################################################################
#
#  Definition of "minimal" basis
#
################################################################################
#     valence basis states
    valence      3  s   2.
    valence      3  p   2.
#     ion occupancy
    ion_occ      3  s   1.
    ion_occ      3  p   1.
################################################################################
#
#  Suggested additional basis functions. For production calculations,
#  uncomment them one after another (the most important basis functions are
#  listed first).
#
#  Constructed for dimers: 1.75 A, 2.0 A, 2.25 A, 2.75 A, 3.75 A
#
################################################################################
#  "First tier" - improvements: -571.96 meV to -37.03 meV
     hydro 3 d 4.2
     hydro 2 p 1.4
     hydro 4 f 6.2
     ionic 3 s auto
#  "Second tier" - improvements: -16.76 meV to -3.03 meV
     hydro 3 d 9
     hydro 5 g 9.4
#     hydro 4 p 4
#     hydro 1 s 0.65
#  "Third tier" - improvements: -3.89 meV to -0.60 meV
#     ionic 3 d auto
#     hydro 3 s 2.6
#     hydro 4 f 8.4
#     hydro 3 d 3.4
#     hydro 3 p 7.8
#  "Fourth tier" - improvements: -0.33 meV to -0.11 meV
#     hydro 2 p 1.6
#     hydro 5 g 10.8
#     hydro 5 f 11.2
#     hydro 3 d 1
#     hydro 4 s 4.5
#  Further basis functions that fell out of the optimization - noise
#  level... < -0.08 meV
#     hydro 4 d 6.6
#     hydro 5 g 16.4
#     hydro 4 d 9
################################################################################
#
# For methods that use the localized form of the "resolution of identity" for
# the two-electron Coulomb operator (RI_method LVL), particularly Hartree-Fock and
# hybrid density functional calculations, the highest accuracy can be obtained by
# uncommenting the line beginning with "for_aux"  below, thus adding an extra g radial
# function to the construction of the product basis set for the expansion.
# See Ref. New J. Phys. 17, 093020 (2015) for more information, particularly Figs. 1 and 6.
#
################################################################################
#
# for_aux hydro 5 g 6.0""" # noqa: E501

species_out_content = """################################################################################
#
#  FHI-aims code project
#  Volker Blum, Fritz Haber Institute Berlin, 2009
#
#  Suggested "tight" defaults for Si atom (to be pasted into control.in file)
#
#  Revised Jan 04, 2011, following tests (SiC) done by Lydia Nemec:
#     d and g functions of tier 2 now enabled by default.
#
################################################################################

  species               Si
#     global species definitions
  nucleus               14.0
  mass                  28.0855
#
  l_hartree             6
#
  cut_pot               4.0 2.0 1.0
  basis_dep_cutoff      0.001
#
  radial_base    42   7.0000
  radial_multiplier        2
  angular_grids  specified
  division       0.4121   50
  division       0.7665  110
  division       1.0603  194
  division       1.2846  302
  division       1.4125  434
  outer_grid     434
##################################################################################
#
# Optional basis settings passed to pyfhiaims
#
##################################################################################
  cut_atomic_basis      True
  cut_core              infinte 2.0
  innermost_max         5
    plus_u    2 p 0.5
    plus_u    3 d 0.25
##################################################################################
#
#  Definition of "minimal" basis
#
##################################################################################
#     valence basis states
    valence      3  s   2.
    valence      3  p   2.
#     ion occupancy
    ion_occ      3  s   1.
    ion_occ      3  p   1.
##################################################################################
#
#  Suggested additional basis functions. For production calculations,
#  uncomment them one after another (the most important basis functions are
#  listed first).
#
#  These were set using pyfhiaims, original may files have additional comments
#
##################################################################################
#  First tier
             hydro      3  d  4.2
             hydro      2  p  1.4
             hydro      4  f  6.2
             ionic      3  s  auto
#  Second tier
             hydro      3  d  9.0
             hydro      5  g  9.4
#            hydro      4  p  4.0
#            hydro      1  s  0.65
#  Third tier
#            ionic      3  d  auto
#            hydro      3  s  2.6
#            hydro      4  f  8.4
#            hydro      3  d  3.4
#            hydro      3  p  7.8
#  Fourth tier
#            hydro      2  p  1.6
#            hydro      5  g  10.8
#            hydro      5  f  11.2
#            hydro      3  d  1.0
#            hydro      4  s  4.5
#  Further basis functions
#            hydro      4  d  6.6
#            hydro      5  g  16.4
#            hydro      4  d  9.0""" # noqa: E501


def test_species_defaults():
    """Test the species defaults"""
    speceis_default = SpeciesDefaults.from_strings(species_content_in.splitlines())

    assert str(speceis_default) == speceis_default.content
    assert speceis_default.content == species_out_content
