(git:92574dc)
Loading...
Searching...
No Matches
cp_units Module Reference

unit conversion facility More...

Data Types

type  cp_unit_type
 stores a unit More...
type  cp_unit_set_type
 stores the default units to be used More...

Functions/Subroutines

subroutine, public cp_unit_create (unit, string)
 creates a unit parsing a string
elemental subroutine, public cp_unit_release (unit)
 releases the given unit
character(len=cp_unit_desc_length) function, public cp_unit_desc (unit, defaults, accept_undefined)
 returns the "name" of the given unit
real(kind=dp) function, public cp_unit_to_cp2k1 (value, unit, defaults, power)
 transform a value to the internal cp2k units
real(kind=dp) function, public cp_unit_from_cp2k1 (value, unit, defaults, power)
 converts from the internal cp2k units to the given unit
real(kind=dp) function, public cp_unit_to_cp2k (value, unit_str, defaults, power)
 converts to the internal cp2k units to the given unit
real(kind=dp) function, public cp_unit_from_cp2k (value, unit_str, defaults, power)
 converts from the internal cp2k units to the given unit
logical function, public cp_unit_compatible (ref_unit, unit)
 returs true if the two units are compatible
subroutine, public cp_unit_set_create (unit_set, name)
 initializes the given unit set
subroutine, public cp_unit_set_release (unit_set)
 releases the given unit set
subroutine, public export_units_as_xml (iw)
 Exports all available units as XML.

Variables

integer, parameter, public cp_ukind_none = 0
integer, parameter, public cp_ukind_energy = 1
integer, parameter, public cp_ukind_length = 2
integer, parameter, public cp_ukind_temperature = 3
integer, parameter, public cp_ukind_angle = 4
integer, parameter, public cp_ukind_pressure = 5
integer, parameter, public cp_ukind_time = 6
integer, parameter, public cp_ukind_mass = 7
integer, parameter, public cp_ukind_undef = 8
integer, parameter, public cp_ukind_potential = 9
integer, parameter, public cp_ukind_force = 10
integer, parameter, public cp_ukind_efield = 11
integer, parameter, public cp_ukind_max = 11
integer, parameter, public cp_units_none = 100
integer, parameter, public cp_units_au = 101
integer, parameter, public cp_units_m_e = 110
integer, parameter, public cp_units_amu = 111
integer, parameter, public cp_units_kg = 112
integer, parameter, public cp_units_hartree = 130
integer, parameter, public cp_units_wavenum = 131
integer, parameter, public cp_units_joule = 132
integer, parameter, public cp_units_kcalmol = 133
integer, parameter, public cp_units_ry = 134
integer, parameter, public cp_units_ev = 135
integer, parameter, public cp_units_kjmol = 136
integer, parameter, public cp_units_jmol = 137
integer, parameter, public cp_units_kev = 138
integer, parameter, public cp_units_bohr = 140
integer, parameter, public cp_units_angstrom = 141
integer, parameter, public cp_units_m = 142
integer, parameter, public cp_units_pm = 143
integer, parameter, public cp_units_nm = 144
integer, parameter, public cp_units_k = 150
integer, parameter, public cp_units_bar = 161
integer, parameter, public cp_units_atm = 162
integer, parameter, public cp_units_kbar = 163
integer, parameter, public cp_units_pa = 164
integer, parameter, public cp_units_mpa = 165
integer, parameter, public cp_units_gpa = 166
integer, parameter, public cp_units_rad = 170
integer, parameter, public cp_units_deg = 171
integer, parameter, public cp_units_fs = 180
integer, parameter, public cp_units_s = 181
integer, parameter, public cp_units_wn = 182
integer, parameter, public cp_units_ps = 183
integer, parameter, public cp_units_volt = 190
integer, parameter, public cp_units_newton = 200
integer, parameter, public cp_units_mnewton = 201
integer, parameter, public cp_units_volt_per_m = 202
integer, parameter, public cp_units_volt_per_nm = 203
integer, parameter, public cp_units_volt_per_angstrom = 204
integer, parameter, public cp_unit_max_kinds = 8
integer, parameter, public cp_unit_basic_desc_length = 15
integer, parameter, public cp_unit_desc_length = cp_unit_max_kinds*cp_unit_basic_desc_length

Detailed Description

unit conversion facility

Units are complex, this module does not try to be very smart, for
example SI prefixes are not supported automatically, and
which kinds are really basic can change depending on the system of
units chosen, and equivalences are not always catched.

This is thought as a simple conversion facility for the input and output.
If you need something more you are probably better off using the
physcon module directly.
Note
One design choice was not to use dynamically allocated elements to reduce the possibility of leaks. Needs to be extended (for example charge, dipole,...) I just added the units and kinds that I needed. Used by the parser Should keep an unsorted/uncompressed version for nicer labels?
History
01.2005 created [fawzi]
Author
fawzi

Function/Subroutine Documentation

◆ cp_unit_create()

subroutine, public cp_units::cp_unit_create ( type(cp_unit_type), intent(out) unit,
character(len=*), intent(in) string )

creates a unit parsing a string

Parameters
unitthe unit to initialize
stringthe string containing the description of the unit
Author
fawzi

Definition at line 167 of file cp_units.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cp_unit_release()

elemental subroutine, public cp_units::cp_unit_release ( type(cp_unit_type), intent(in) unit)

releases the given unit

Parameters
unitthe unit to release
Author
fawzi
Note
at the moment not needed, there for completeness

Definition at line 565 of file cp_units.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cp_unit_desc()

character(len=cp_unit_desc_length) function, public cp_units::cp_unit_desc ( type(cp_unit_type), intent(in) unit,
type(cp_unit_set_type), intent(in), optional defaults,
logical, intent(in), optional accept_undefined )

returns the "name" of the given unit

Parameters
unitthe unit to describe
defaultsdefaults for the undefined units, optional
accept_undefinedif defaults is not present or is not associated whether undefined units should be accepted (defaults to false)
Returns
...
Author
fawzi

Definition at line 1106 of file cp_units.F.

Here is the caller graph for this function:

◆ cp_unit_to_cp2k1()

real(kind=dp) function, public cp_units::cp_unit_to_cp2k1 ( real(kind=dp), intent(in) value,
type(cp_unit_type), intent(in) unit,
type(cp_unit_set_type), intent(in), optional defaults,
integer, intent(in), optional power )

transform a value to the internal cp2k units

Parameters
valuethe value to convert
unitthe unit of the result
defaultsthe defaults unit for those that are left free (cp_units_none)
powerthe power of the unit (defaults to 1)
Returns
...
Author
fawzi

Definition at line 1156 of file cp_units.F.

Here is the caller graph for this function:

◆ cp_unit_from_cp2k1()

real(kind=dp) function, public cp_units::cp_unit_from_cp2k1 ( real(kind=dp), intent(in) value,
type(cp_unit_type), intent(in) unit,
type(cp_unit_set_type), intent(in), optional defaults,
integer, intent(in), optional power )

converts from the internal cp2k units to the given unit

Parameters
valuethe value to convert
unitthe unit of the result
defaultsthe defaults unit for those that are left free (cp_units_none)
powerthe power of the unit (defaults to 1)
Returns
...
Author
fawzi

Definition at line 1192 of file cp_units.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cp_unit_to_cp2k()

real(kind=dp) function, public cp_units::cp_unit_to_cp2k ( real(kind=dp), intent(in) value,
character(len=*), intent(in) unit_str,
type(cp_unit_set_type), intent(in), optional defaults,
integer, intent(in), optional power )

converts to the internal cp2k units to the given unit

Parameters
valuethe value to convert
unit_strthe unit of the result as string
defaultsthe defaults unit for those that are left free (cp_units_none)
powerthe power of the unit (defaults to 1)
Returns
...
Author
fawzi

Definition at line 1221 of file cp_units.F.

Here is the call graph for this function:

◆ cp_unit_from_cp2k()

real(kind=dp) function, public cp_units::cp_unit_from_cp2k ( real(kind=dp), intent(in) value,
character(len=*), intent(in) unit_str,
type(cp_unit_set_type), intent(in), optional defaults,
integer, intent(in), optional power )

converts from the internal cp2k units to the given unit

Parameters
valuethe value to convert
unit_strthe unit of the result as string
defaultsthe defaults unit for those that are left free (cp_units_none)
powerthe power of the unit (defaults to 1)
Returns
...
Author
fawzi

Definition at line 1250 of file cp_units.F.

Here is the call graph for this function:

◆ cp_unit_compatible()

logical function, public cp_units::cp_unit_compatible ( type(cp_unit_type), intent(in) ref_unit,
type(cp_unit_type), intent(in) unit )

returs true if the two units are compatible

Parameters
ref_unit...
unit...
Returns
...
Author
Teodoro Laino [tlaino] - 11.2007 - University of Zurich

Definition at line 1276 of file cp_units.F.

Here is the caller graph for this function:

◆ cp_unit_set_create()

subroutine, public cp_units::cp_unit_set_create ( type(cp_unit_set_type), intent(out) unit_set,
character(len=*), intent(in) name )

initializes the given unit set

Parameters
unit_setthe set to initialize
namethe name of the set, used for the dafault initialization of the various units
Author
fawzi

Definition at line 1299 of file cp_units.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cp_unit_set_release()

subroutine, public cp_units::cp_unit_set_release ( type(cp_unit_set_type), intent(inout) unit_set)

releases the given unit set

Parameters
unit_setthe unit set to release
Author
fawzi

Definition at line 1373 of file cp_units.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_units_as_xml()

subroutine, public cp_units::export_units_as_xml ( integer, intent(in) iw)

Exports all available units as XML.

Parameters
iw...
Author
Ole Schuett

Definition at line 1390 of file cp_units.F.

Here is the caller graph for this function:

Variable Documentation

◆ cp_ukind_none

integer, parameter, public cp_units::cp_ukind_none = 0

Definition at line 50 of file cp_units.F.

◆ cp_ukind_energy

integer, parameter, public cp_units::cp_ukind_energy = 1

Definition at line 50 of file cp_units.F.

◆ cp_ukind_length

integer, parameter, public cp_units::cp_ukind_length = 2

Definition at line 50 of file cp_units.F.

◆ cp_ukind_temperature

integer, parameter, public cp_units::cp_ukind_temperature = 3

Definition at line 50 of file cp_units.F.

◆ cp_ukind_angle

integer, parameter, public cp_units::cp_ukind_angle = 4

Definition at line 50 of file cp_units.F.

◆ cp_ukind_pressure

integer, parameter, public cp_units::cp_ukind_pressure = 5

Definition at line 50 of file cp_units.F.

◆ cp_ukind_time

integer, parameter, public cp_units::cp_ukind_time = 6

Definition at line 50 of file cp_units.F.

◆ cp_ukind_mass

integer, parameter, public cp_units::cp_ukind_mass = 7

Definition at line 50 of file cp_units.F.

◆ cp_ukind_undef

integer, parameter, public cp_units::cp_ukind_undef = 8

Definition at line 50 of file cp_units.F.

◆ cp_ukind_potential

integer, parameter, public cp_units::cp_ukind_potential = 9

Definition at line 50 of file cp_units.F.

◆ cp_ukind_force

integer, parameter, public cp_units::cp_ukind_force = 10

Definition at line 50 of file cp_units.F.

◆ cp_ukind_efield

integer, parameter, public cp_units::cp_ukind_efield = 11

Definition at line 50 of file cp_units.F.

◆ cp_ukind_max

integer, parameter, public cp_units::cp_ukind_max = 11

Definition at line 50 of file cp_units.F.

◆ cp_units_none

integer, parameter, public cp_units::cp_units_none = 100

Definition at line 65 of file cp_units.F.

◆ cp_units_au

integer, parameter, public cp_units::cp_units_au = 101

Definition at line 65 of file cp_units.F.

◆ cp_units_m_e

integer, parameter, public cp_units::cp_units_m_e = 110

Definition at line 68 of file cp_units.F.

◆ cp_units_amu

integer, parameter, public cp_units::cp_units_amu = 111

Definition at line 68 of file cp_units.F.

◆ cp_units_kg

integer, parameter, public cp_units::cp_units_kg = 112

Definition at line 68 of file cp_units.F.

◆ cp_units_hartree

integer, parameter, public cp_units::cp_units_hartree = 130

Definition at line 72 of file cp_units.F.

◆ cp_units_wavenum

integer, parameter, public cp_units::cp_units_wavenum = 131

Definition at line 72 of file cp_units.F.

◆ cp_units_joule

integer, parameter, public cp_units::cp_units_joule = 132

Definition at line 72 of file cp_units.F.

◆ cp_units_kcalmol

integer, parameter, public cp_units::cp_units_kcalmol = 133

Definition at line 72 of file cp_units.F.

◆ cp_units_ry

integer, parameter, public cp_units::cp_units_ry = 134

Definition at line 72 of file cp_units.F.

◆ cp_units_ev

integer, parameter, public cp_units::cp_units_ev = 135

Definition at line 72 of file cp_units.F.

◆ cp_units_kjmol

integer, parameter, public cp_units::cp_units_kjmol = 136

Definition at line 72 of file cp_units.F.

◆ cp_units_jmol

integer, parameter, public cp_units::cp_units_jmol = 137

Definition at line 72 of file cp_units.F.

◆ cp_units_kev

integer, parameter, public cp_units::cp_units_kev = 138

Definition at line 72 of file cp_units.F.

◆ cp_units_bohr

integer, parameter, public cp_units::cp_units_bohr = 140

Definition at line 83 of file cp_units.F.

◆ cp_units_angstrom

integer, parameter, public cp_units::cp_units_angstrom = 141

Definition at line 83 of file cp_units.F.

◆ cp_units_m

integer, parameter, public cp_units::cp_units_m = 142

Definition at line 83 of file cp_units.F.

◆ cp_units_pm

integer, parameter, public cp_units::cp_units_pm = 143

Definition at line 83 of file cp_units.F.

◆ cp_units_nm

integer, parameter, public cp_units::cp_units_nm = 144

Definition at line 83 of file cp_units.F.

◆ cp_units_k

integer, parameter, public cp_units::cp_units_k = 150

Definition at line 90 of file cp_units.F.

◆ cp_units_bar

integer, parameter, public cp_units::cp_units_bar = 161

Definition at line 93 of file cp_units.F.

◆ cp_units_atm

integer, parameter, public cp_units::cp_units_atm = 162

Definition at line 94 of file cp_units.F.

◆ cp_units_kbar

integer, parameter, public cp_units::cp_units_kbar = 163

Definition at line 95 of file cp_units.F.

◆ cp_units_pa

integer, parameter, public cp_units::cp_units_pa = 164

Definition at line 96 of file cp_units.F.

◆ cp_units_mpa

integer, parameter, public cp_units::cp_units_mpa = 165

Definition at line 97 of file cp_units.F.

◆ cp_units_gpa

integer, parameter, public cp_units::cp_units_gpa = 166

Definition at line 98 of file cp_units.F.

◆ cp_units_rad

integer, parameter, public cp_units::cp_units_rad = 170

Definition at line 101 of file cp_units.F.

◆ cp_units_deg

integer, parameter, public cp_units::cp_units_deg = 171

Definition at line 101 of file cp_units.F.

◆ cp_units_fs

integer, parameter, public cp_units::cp_units_fs = 180

Definition at line 105 of file cp_units.F.

◆ cp_units_s

integer, parameter, public cp_units::cp_units_s = 181

Definition at line 105 of file cp_units.F.

◆ cp_units_wn

integer, parameter, public cp_units::cp_units_wn = 182

Definition at line 105 of file cp_units.F.

◆ cp_units_ps

integer, parameter, public cp_units::cp_units_ps = 183

Definition at line 105 of file cp_units.F.

◆ cp_units_volt

integer, parameter, public cp_units::cp_units_volt = 190

Definition at line 111 of file cp_units.F.

◆ cp_units_newton

integer, parameter, public cp_units::cp_units_newton = 200

Definition at line 114 of file cp_units.F.

◆ cp_units_mnewton

integer, parameter, public cp_units::cp_units_mnewton = 201

Definition at line 114 of file cp_units.F.

◆ cp_units_volt_per_m

integer, parameter, public cp_units::cp_units_volt_per_m = 202

Definition at line 118 of file cp_units.F.

◆ cp_units_volt_per_nm

integer, parameter, public cp_units::cp_units_volt_per_nm = 203

Definition at line 118 of file cp_units.F.

◆ cp_units_volt_per_angstrom

integer, parameter, public cp_units::cp_units_volt_per_angstrom = 204

Definition at line 118 of file cp_units.F.

◆ cp_unit_max_kinds

integer, parameter, public cp_units::cp_unit_max_kinds = 8

Definition at line 122 of file cp_units.F.

◆ cp_unit_basic_desc_length

integer, parameter, public cp_units::cp_unit_basic_desc_length = 15

Definition at line 122 of file cp_units.F.

◆ cp_unit_desc_length

integer, parameter, public cp_units::cp_unit_desc_length = cp_unit_max_kinds*cp_unit_basic_desc_length

Definition at line 122 of file cp_units.F.