50 logical :: initialized = .false.
51 integer :: default_pseudopotential_set_id
52 type(pseudo_set_t) :: default_pseudopotential_set
53 integer :: default_allelectron_type
54 real(real64) :: default_sigma
55 real(real64) :: default_anc_a
67 class(species_factory_t),
intent(inout) :: factory
68 type(namespace_t),
intent(in) :: namespace
70 integer :: ierr, default_val
72 if (factory%initialized)
return
76 factory%initialized = .
true.
99 call parse_variable(namespace,
'AllElectronType', option__allelectrontype__no, factory%default_allelectron_type)
113 call parse_variable(namespace,
'AllElectronSigma', 0.6_real64, factory%default_sigma)
124 call parse_variable(namespace,
'AllElectronANCParam', 4.0_real64, factory%default_anc_a)
184 default_val = option__pseudopotentialset__standard
185 if(factory%default_allelectron_type /= option__allelectrontype__no) default_val = option__pseudopotentialset__none
186 call parse_variable(namespace,
'PseudopotentialSet', default_val, factory%default_pseudopotential_set_id)
188 if (factory%default_pseudopotential_set_id /= option__pseudopotentialset__none)
then
194 if (factory%default_pseudopotential_set_id /= option__pseudopotentialset__none &
195 .and. factory%default_allelectron_type /= option__allelectrontype__no)
then
196 message(1) =
"PseudopotentialSet /= none cannot be used with AllElectronType /= no."
210 if (factory%initialized)
then
212 factory%initialized = .false.
228 character(len=*),
intent(in) :: label
229 integer,
intent(in) :: index
232 character(len=LABEL_LEN) :: lab
233 integer :: ib, row, n_spec_block, read_data
433 if (
parse_block(namespace,
'Species', blk) == 0)
then
439 block:
do ib = 1, n_spec_block
441 if (trim(lab) == trim(label))
then
449 spec => factory%create_from_block(namespace, blk, row, label, index, read_data)
452 assert(read_data > 0)
463 if(factory%default_allelectron_type /= option__allelectrontype__no)
then
464 select case(factory%default_allelectron_type)
465 case(option__allelectrontype__full_delta)
466 spec =>
full_delta_t(label, index, factory%default_sigma)
467 case(option__allelectrontype__full_gaussian)
469 case(option__allelectrontype__full_anc)
470 spec =>
full_anc_t(label, index, factory%default_anc_a)
481 call spec%set_zval(spec%get_z())
491 call read_from_set(spec, factory%default_pseudopotential_set_id, factory%default_pseudopotential_set, read_data)
493 if (read_data == 0)
then
494 call messages_write(
'Species '//trim(spec%get_label())//
' not found in default pseudopotential set.', new_line=.
true. )
509 function read_from_block(factory, namespace, blk, row, label, index, read_data)
result(spec)
512 type(
block_t),
intent(in) :: blk
513 integer,
intent(in) :: row
514 character(len=*),
intent(in) :: label
515 integer,
intent(in) :: index
516 integer,
intent(out):: read_data
519 integer :: ncols, icol, flag, set_read_data, ierr, type
522 integer :: user_lmax, user_llocal, hubbard_l, pseudopotential_set_id
523 real(real64) :: hubbard_u, hubbard_j, hubbard_alpha, mass, z_val, jradius, jthick, vdw_radius, aa
524 real(real64) :: sigma, softening
525 character(len=MAX_PATH_LEN) :: filename
527 integer,
parameter :: &
534 species_full_gaussian = 124, &
537 species_full_delta = 127, &
538 species_soft_coulomb = 128, &
539 species_full_anc = 130
552 call messages_write(
'Found a species with the old format. Please update', new_line = .
true.)
553 call messages_write(
'the Species block to the new format, where the second', new_line = .
true.)
566 case (species_soft_coulomb)
581 case (species_full_delta)
582 spec =>
full_delta_t(label, index, factory%default_sigma)
584 case (species_full_gaussian)
587 case (species_full_anc)
588 spec =>
full_anc_t(label, index, factory%default_anc_a)
603 call messages_input_error(namespace,
'Species',
"Unknown type for species '"//trim(spec%get_label())//
"'", row=row, column=1)
606 call spec%set_mass(-
m_one)
607 call spec%set_vdw_radius(-
m_one)
608 call spec%set_zval(-
m_one)
614 if (icol >= ncols)
exit
620 case (option__species__lmax)
626 call spec%set_user_lmax(user_lmax)
629 "The 'lmax' parameter in species "//trim(spec%get_label())//
" can only be used with pseudopotential species", &
630 row=row, column=icol+1)
633 if (user_lmax < 0)
then
635 "The 'lmax' parameter in species "//trim(spec%get_label())//
" cannot be negative", &
636 row=row, column=icol+1)
639 case (option__species__lloc)
645 call spec%set_user_lloc(user_llocal)
648 "The 'lloc' parameter in species "//trim(spec%get_label())//
" can only be used with pseudopotential species", &
649 row=row, column=icol+1)
652 if (user_llocal < 0)
then
654 "The 'lloc' parameter in species "//trim(spec%get_label())//
" cannot be negative", row=row, column=icol+1)
657 case (option__species__hubbard_l)
663 call spec%set_hubbard_l(hubbard_l)
666 "The 'hubbard_l' parameter in species "//trim(spec%get_label())//
" can only be used with pseudopotential species", &
667 row=row, column=icol+1)
670 if (hubbard_l < 0)
then
672 "The 'hubbard_l' parameter in species "//trim(spec%get_label())//
" cannot be negative", row=row, column=icol+1)
675 case (option__species__hubbard_u)
678 call spec%set_hubbard_u(hubbard_u)
680 case (option__species__hubbard_alpha)
683 call spec%set_hubbard_alpha(hubbard_alpha)
685 case (option__species__hubbard_j)
688 call spec%set_hubbard_j(hubbard_j)
690 if (abs(abs(spec%get_hubbard_j()-spec%get_hubbard_l())-
m_half) <=
m_epsilon)
then
692 trim(spec%get_label())//
" can only be hubbard_l +/- 1/2", row=row, column=icol+1)
695 case (option__species__mass)
698 call spec%set_mass(mass)
700 case (option__species__valence)
703 call spec%set_zval(z_val)
704 call spec%set_z(z_val)
706 case (option__species__jellium_radius)
710 row=row, column=icol+1)
714 call spec%set_radius(jradius)
716 call messages_input_error(namespace,
'Species',
'jellium_radius can only be used with species_jellium', &
717 row=row, column=icol+1)
720 case (option__species__gaussian_width)
724 row=row, column=icol+1)
727 call spec%set_sigma(sigma)
729 call messages_input_error(namespace,
'Species',
'gaussian_width can only be used with species_full_gaussian', &
730 row=row, column=icol+1)
733 case (option__species__anc_a)
737 row=row, column=icol+1)
743 call messages_input_error(namespace,
'Species',
'anc_a can only be used with species_full_anc', &
744 row=row, column=icol+1)
747 case (option__species__softening)
750 softening = softening**2
754 call spec%set_softening2(softening)
756 call messages_input_error(namespace,
'Species',
'softening can only be used with species_soft_coulomb', &
757 row=row, column=icol+1)
760 case (option__species__file)
763 call spec%set_filename(filename)
765 case (option__species__db_file)
766 call messages_write(
"The 'db_file' option for 'Species' block is obsolete. Please use", new_line = .
true.)
767 call messages_write(
"the option 'set' or the variable 'PseudopotentialSet' instead.")
770 case (option__species__set)
776 spec%pseudopotential_set_initialized = .
true.
777 spec%pseudopotential_set_id = pseudopotential_set_id
781 row=row, column=icol+1)
784 case (option__species__potential_formula)
790 call messages_input_error(namespace,
'Species',
'potential_formula can only be used with species_user_defined', &
791 row=row, column=icol+1)
794 case (option__species__volume)
802 call messages_input_error(namespace,
'Species',
'volume can only be used with species_jellium_charge_density', &
803 row=row, column=icol+1)
806 case (option__species__density_formula)
814 call messages_input_error(namespace,
'Species',
'density_formula can only be used with species_charge_density', &
815 row=row, column=icol+1)
818 case (option__species__thickness)
822 if (jthick <=
m_zero)
then
823 call messages_input_error(namespace,
'Species',
'the value of the thickness parameter in species '&
824 //trim(spec%get_label())//
' must be positive.', row=row, column=icol+1)
829 call spec%set_thickness(jthick)
831 call messages_input_error(namespace,
'Species',
'thickness can only be used with species_jellium_slab', &
832 row=row, column=icol+1)
835 case (option__species__vdw_radius)
838 call spec%set_vdw_radius(vdw_radius)
841 call messages_input_error(namespace,
'Species',
"Unknown parameter in species '"//trim(spec%get_label())//
"'", &
842 row=row, column=icol)
854 "The 'softening' parameter is missing for species "//trim(spec%get_label()))
860 "The 'potential_formula' parameter is missing for species '"//trim(spec%get_label())//
"'")
866 "The 'density_formula' parameter is missing for species '"//trim(spec%get_label())//
"'")
872 "The 'file' or 'db_file' parameter is missing for species '"//trim(spec%get_label())//
"'")
878 "The 'thickness' parameter is missing for species '"//trim(spec%get_label())//
"'")
884 "The 'volume' parameter is missing for species '"//trim(spec%get_label())//
"'")
889 if (spec%get_user_lloc() > spec%get_user_lmax())
then
891 "the 'lloc' parameter cannot be larger than the 'lmax' parameter in species "//trim(spec%get_label()))
900 spec%pseudopotential_set_id = factory%default_pseudopotential_set_id
901 spec%pseudopotential_set = factory%default_pseudopotential_set
904 call read_from_set(spec, spec%pseudopotential_set_id, spec%pseudopotential_set, set_read_data)
906 if (set_read_data == 0)
then
907 call messages_write(
'Species '//trim(spec%get_label())//
' is not defined in the requested pseudopotential set.', &
924 if (spec%get_zval() <
m_zero)
then
925 call spec%set_zval(spec%get_z())
932 if (spec%get_zval() <
m_zero)
then
933 call spec%set_zval(spec%get_z())
940 if (spec%get_zval() <
m_zero)
then
941 call spec%set_zval(spec%get_z())
946 call spec%set_mass(
m_one)
947 call messages_write(
'Info: default mass for species '//trim(spec%get_label())//
':')
954 call spec%set_vdw_radius(
m_zero)
955 call messages_write(
'Info: default vdW radius for species '//trim(spec%get_label())//
':')
962 if (spec%is_user_defined())
then
963 call spec%set_zval(
m_zero)
966 "The 'valence' parameter is missing for species '"//trim(spec%get_label())//
"'")
979 integer(int64),
intent(in) :: param
992 integer(int64),
intent(in) :: param
997 call messages_input_error(namespace,
'Species',
"Duplicated parameter in species '"//trim(spec%get_label())//
"'")
1012 call messages_write(
'Cannot determine the element for species '//trim(spec%get_label())//
'.')
1018 if (spec%get_mass() <
m_zero)
then
1020 call messages_write(
'Info: default mass for species '//trim(spec%get_label())//
':')
1026 if (spec%get_vdw_radius() <
m_zero)
then
1028 if (spec%get_vdw_radius() <
m_zero)
then
1029 call spec%set_vdw_radius(
m_zero)
1030 call messages_write(
"The default vdW radius for species '"//trim(spec%get_label())//
"' is not defined.", &
1032 call messages_write(
"You can specify the vdW radius in %Species block.")
1035 call messages_write(
'Info: default vdW radius for species '//trim(spec%get_label())//
':')
subroutine check_duplication(param)
logical function parameter_defined(param)
logical function, public element_valid(self)
real(real64), parameter, public m_zero
real(real64), parameter, public m_epsilon
type(conf_t), public conf
Global instance of Octopus configuration.
real(real64), parameter, public m_half
real(real64), parameter, public m_one
This module implements a simple hash table for non-negative integer keys and integer values.
subroutine, public iihash_end(h)
Free a hash table.
subroutine, public iihash_insert(h, key, val)
Insert a (key, val) pair into the hash table h.
integer function, public iihash_lookup(h, key, found)
Look up a value in the hash table h. If found is present, it indicates if key could be found in the t...
subroutine, public iihash_init(h)
Initialize a hash table h.
integer, parameter, public species_charge_density
user-defined function for charge density
integer, parameter, public species_jellium_charge_density
jellium volume read from file
integer, parameter, public species_jellium
jellium sphere.
integer, parameter, public species_from_file
integer, parameter, public species_usdef
user-defined function for local potential
integer, parameter, public species_jellium_slab
jellium slab.
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_obsolete_variable(namespace, name, rep)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public pseudo_set_init(pseudo_set, dirname, ierr)
character(len=max_path_len) function, public get_set_directory(set_id)
subroutine, public read_from_set(spec, set_id, set, read_data)
Creates a pseudopotential type from a set.
integer, parameter, public species_pseudo
pseudopotential
integer, parameter, public species_pspio
pseudopotential parsed by pspio library
subroutine, public share_directory_set(dir)
class(species_t) function, pointer species_factory_create_from_input(factory, namespace, label, index)
Reads the information (from the input file) about a species_t variable, initializing part of it (it h...
subroutine, public species_factory_init(factory, namespace)
class(species_t) function, pointer read_from_block(factory, namespace, blk, row, label, index, read_data)
Parses the species block for a given species.
subroutine, public species_factory_end(factory)
character(kind=c_char) function, dimension(label_len+1), public get_symbol(label)
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.
type(unit_system_t), public units_inp
the units systems for reading and writing
subroutine check_real_atom_species()
An abstract class for species. Derived classes include jellium, all electron, and pseudopotential spe...