49 logical :: initialized = .false.
50 integer :: default_pseudopotential_set_id
51 type(pseudo_set_t) :: default_pseudopotential_set
52 integer :: default_allelectron_type
53 real(real64) :: default_sigma
54 real(real64) :: default_anc_a
66 class(species_factory_t),
intent(inout) :: factory
67 type(namespace_t),
intent(in) :: namespace
69 integer :: ierr, default_val
71 if (factory%initialized)
return
75 factory%initialized = .
true.
77 call share_directory_set(
conf%share)
98 call parse_variable(namespace,
'AllElectronType', option__allelectrontype__no, factory%default_allelectron_type)
112 call parse_variable(namespace,
'AllElectronSigma', 0.6_real64, factory%default_sigma)
123 call parse_variable(namespace,
'AllElectronANCParam', 4.0_real64, factory%default_anc_a)
178 default_val = option__pseudopotentialset__standard
179 if(factory%default_allelectron_type /= option__allelectrontype__no) default_val = option__pseudopotentialset__none
180 call parse_variable(namespace,
'PseudopotentialSet', default_val, factory%default_pseudopotential_set_id)
182 if (factory%default_pseudopotential_set_id /= option__pseudopotentialset__none)
then
188 if (factory%default_pseudopotential_set_id /= option__pseudopotentialset__none .and. factory%default_allelectron_type /= option__allelectrontype__no)
then
189 message(1) =
"PseudopotentialSet /= none cannot be used with AllElectronType /= no."
203 if (factory%initialized)
then
205 factory%initialized = .false.
221 character(len=*),
intent(in) :: label
222 integer,
intent(in) :: index
225 character(len=LABEL_LEN) :: lab
226 integer :: ib, row, n_spec_block, read_data
426 if (
parse_block(namespace,
'Species', blk) == 0)
then
432 block:
do ib = 1, n_spec_block
434 if (trim(lab) == trim(label))
then
442 spec => factory%create_from_block(namespace, blk, row, label, index, read_data)
445 assert(read_data > 0)
456 if(factory%default_allelectron_type /= 0)
then
457 select case(factory%default_allelectron_type)
458 case(option__allelectrontype__full_delta)
459 spec =>
full_delta_t(label, index, factory%default_sigma)
460 case(option__allelectrontype__full_gaussian)
462 case(option__allelectrontype__full_anc)
463 spec =>
full_anc_t(label, index, factory%default_anc_a)
474 call spec%set_zval(spec%get_z())
484 call read_from_set(spec, factory%default_pseudopotential_set_id, factory%default_pseudopotential_set, read_data)
486 if (read_data == 0)
then
487 call messages_write(
'Species '//trim(spec%get_label())//
' not found in default pseudopotential set.', new_line=.
true. )
502 function read_from_block(factory, namespace, blk, row, label, index, read_data)
result(spec)
505 type(
block_t),
intent(in) :: blk
506 integer,
intent(in) :: row
507 character(len=*),
intent(in) :: label
508 integer,
intent(in) :: index
509 integer,
intent(out):: read_data
512 integer :: ncols, icol, flag, set_read_data, ierr, type
515 integer :: user_lmax, user_llocal, hubbard_l, pseudopotential_set_id
516 real(real64) :: hubbard_u, hubbard_j, hubbard_alpha, mass, z_val, jradius, jthick, vdw_radius, aa
517 real(real64) :: sigma, softening
518 character(len=MAX_PATH_LEN) :: filename
520 integer,
parameter :: &
527 species_full_gaussian = 124, &
530 species_full_delta = 127, &
531 species_soft_coulomb = 128, &
532 species_full_anc = 130
545 call messages_write(
'Found a species with the old format. Please update', new_line = .
true.)
546 call messages_write(
'the Species block to the new format, where the second', new_line = .
true.)
559 case (species_soft_coulomb)
574 case (species_full_delta)
575 spec =>
full_delta_t(label, index, factory%default_sigma)
577 case (species_full_gaussian)
580 case (species_full_anc)
581 spec =>
full_anc_t(label, index, factory%default_anc_a)
596 call messages_input_error(namespace,
'Species',
"Unknown type for species '"//trim(spec%get_label())//
"'", row=row, column=1)
599 call spec%set_mass(-
m_one)
600 call spec%set_vdw_radius(-
m_one)
601 call spec%set_zval(-
m_one)
607 if (icol >= ncols)
exit
613 case (option__species__lmax)
619 call spec%set_user_lmax(user_lmax)
622 "The 'lmax' parameter in species "//trim(spec%get_label())//
" can only be used with pseudopotential species", &
623 row=row, column=icol+1)
626 if (user_lmax < 0)
then
628 "The 'lmax' parameter in species "//trim(spec%get_label())//
" cannot be negative", &
629 row=row, column=icol+1)
632 case (option__species__lloc)
638 call spec%set_user_lloc(user_llocal)
641 "The 'lloc' parameter in species "//trim(spec%get_label())//
" can only be used with pseudopotential species", &
642 row=row, column=icol+1)
645 if (user_llocal < 0)
then
647 "The 'lloc' parameter in species "//trim(spec%get_label())//
" cannot be negative", row=row, column=icol+1)
650 case (option__species__hubbard_l)
656 call spec%set_hubbard_l(hubbard_l)
659 "The 'hubbard_l' parameter in species "//trim(spec%get_label())//
" can only be used with pseudopotential species", &
660 row=row, column=icol+1)
663 if (hubbard_l < 0)
then
665 "The 'hubbard_l' parameter in species "//trim(spec%get_label())//
" cannot be negative", row=row, column=icol+1)
668 case (option__species__hubbard_u)
671 call spec%set_hubbard_u(hubbard_u)
673 case (option__species__hubbard_alpha)
676 call spec%set_hubbard_u(hubbard_alpha)
678 case (option__species__hubbard_j)
681 call spec%set_hubbard_u(hubbard_alpha)
683 if (abs(abs(spec%get_hubbard_j()-spec%get_hubbard_l())-
m_half) <=
m_epsilon)
then
685 trim(spec%get_label())//
" can only be hubbard_l +/- 1/2", row=row, column=icol+1)
688 case (option__species__mass)
691 call spec%set_mass(mass)
693 case (option__species__valence)
696 call spec%set_zval(z_val)
697 call spec%set_z(z_val)
699 case (option__species__jellium_radius)
703 row=row, column=icol+1)
707 call spec%set_radius(jradius)
709 call messages_input_error(namespace,
'Species',
'jellium_radius can only be used with species_jellium', &
710 row=row, column=icol+1)
713 case (option__species__gaussian_width)
717 row=row, column=icol+1)
720 call spec%set_sigma(sigma)
722 call messages_input_error(namespace,
'Species',
'gaussian_width can only be used with species_full_gaussian', &
723 row=row, column=icol+1)
726 case (option__species__anc_a)
730 row=row, column=icol+1)
736 call messages_input_error(namespace,
'Species',
'anc_a can only be used with species_full_anc', &
737 row=row, column=icol+1)
740 case (option__species__softening)
743 softening = softening**2
747 call spec%set_softening(softening)
749 call messages_input_error(namespace,
'Species',
'softening can only be used with species_soft_coulomb', &
750 row=row, column=icol+1)
753 case (option__species__file)
756 call spec%set_filename(filename)
758 case (option__species__db_file)
759 call messages_write(
"The 'db_file' option for 'Species' block is obsolete. Please use", new_line = .
true.)
760 call messages_write(
"the option 'set' or the variable 'PseudopotentialSet' instead.")
763 case (option__species__set)
769 spec%pseudopotential_set_initialized = .
true.
770 spec%pseudopotential_set_id = pseudopotential_set_id
774 row=row, column=icol+1)
777 case (option__species__potential_formula)
784 call messages_input_error(namespace,
'Species',
'potential_formula can only be used with species_user_defined', &
785 row=row, column=icol+1)
788 case (option__species__volume)
797 call messages_input_error(namespace,
'Species',
'volume can only be used with species_jellium_charge_density', &
798 row=row, column=icol+1)
801 case (option__species__density_formula)
810 call messages_input_error(namespace,
'Species',
'density_formula can only be used with species_charge_density', &
811 row=row, column=icol+1)
814 case (option__species__thickness)
818 if (jthick <=
m_zero)
then
819 call messages_input_error(namespace,
'Species',
'the value of the thickness parameter in species '&
820 //trim(spec%get_label())//
' must be positive.', row=row, column=icol+1)
825 call spec%set_thickness(jthick)
827 call messages_input_error(namespace,
'Species',
'thickness can only be used with species_jellium_slab', &
828 row=row, column=icol+1)
831 case (option__species__vdw_radius)
834 call spec%set_vdw_radius(vdw_radius)
837 call messages_input_error(namespace,
'Species',
"Unknown parameter in species '"//trim(spec%get_label())//
"'", &
838 row=row, column=icol)
850 "The 'softening' parameter is missing for species "//trim(spec%get_label()))
856 "The 'potential_formula' parameter is missing for species '"//trim(spec%get_label())//
"'")
862 "The 'density_formula' parameter is missing for species '"//trim(spec%get_label())//
"'")
868 "The 'file' or 'db_file' parameter is missing for species '"//trim(spec%get_label())//
"'")
874 "The 'thickness' parameter is missing for species '"//trim(spec%get_label())//
"'")
880 "The 'volume' parameter is missing for species '"//trim(spec%get_label())//
"'")
885 if (spec%get_user_lloc() > spec%get_user_lmax())
then
887 "the 'lloc' parameter cannot be larger than the 'lmax' parameter in species "//trim(spec%get_label()))
896 spec%pseudopotential_set_id = factory%default_pseudopotential_set_id
897 spec%pseudopotential_set = factory%default_pseudopotential_set
900 call read_from_set(spec, spec%pseudopotential_set_id, spec%pseudopotential_set, set_read_data)
902 if (set_read_data == 0)
then
903 call messages_write(
'Species '//trim(spec%get_label())//
' is not defined in the requested pseudopotential set.', &
920 if (spec%get_zval() <
m_zero)
then
921 call spec%set_zval(spec%get_z())
928 if (spec%get_zval() <
m_zero)
then
929 call spec%set_zval(spec%get_z())
936 if (spec%get_zval() <
m_zero)
then
937 call spec%set_zval(spec%get_z())
942 call spec%set_mass(
m_one)
943 call messages_write(
'Info: default mass for species '//trim(spec%get_label())//
':')
950 call spec%set_vdw_radius(
m_zero)
951 call messages_write(
'Info: default vdW radius for species '//trim(spec%get_label())//
':')
958 if (spec%is_user_defined())
then
959 call spec%set_zval(
m_zero)
962 "The 'valence' parameter is missing for species '"//trim(spec%get_label())//
"'")
975 integer(int64),
intent(in) :: param
988 integer(int64),
intent(in) :: param
993 call messages_input_error(namespace,
'Species',
"Duplicated parameter in species '"//trim(spec%get_label())//
"'")
1008 call messages_write(
'Cannot determine the element for species '//trim(spec%get_label())//
'.')
1014 if (spec%get_mass() <
m_zero)
then
1016 call messages_write(
'Info: default mass for species '//trim(spec%get_label())//
':')
1022 if (spec%get_vdw_radius() <
m_zero)
then
1024 if (spec%get_vdw_radius() <
m_zero)
then
1025 call spec%set_vdw_radius(
m_zero)
1026 call messages_write(
"The default vdW radius for species '"//trim(spec%get_label())//
"' is not defined.", &
1028 call messages_write(
"You can specify the vdW radius in %Species block.")
1031 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)
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
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)
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
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(len=label_len) function, public get_symbol(label)
subroutine, public conv_to_c_string(str)
converts to c string
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...