41 real(real64),
pointer :: system_charge(:) => null()
42 real(real64),
pointer,
public :: system_pos(:,:) => null()
43 real(real64),
pointer :: system_vel(:,:) => null()
45 real(real64),
allocatable,
public :: partner_e_field(:,:)
47 real(real64),
allocatable,
public :: partner_b_field(:,:)
65 class(interaction_partner_t),
target,
intent(inout) :: partner
66 class(lorentz_force_t),
pointer :: this
72 this%label =
"lorentz_force"
74 this%partner => partner
77 this%system_quantities = [
character(8) ::
"position",
"velocity",
"charge"]
80 this%couplings_from_partner = [
"E field",
"B field"]
81 this%intra_interaction = .false.
88 subroutine lorentz_force_init(this, dim, system_np, system_charge, system_pos, system_vel, namespace)
89 class(lorentz_force_t),
intent(inout) :: this
90 integer,
intent(in) :: dim
91 integer,
intent(in) :: system_np
92 real(real64),
target,
intent(in) :: system_charge(:)
93 real(real64),
target,
intent(in) :: system_pos(:,:)
94 real(real64),
target,
intent(in) :: system_vel(:,:)
95 type(namespace_t),
intent(in) :: namespace
99 message(1) =
"Energies for Lorentz forces are not yet implemented, and currently set to 0."
103 this%system_np = system_np
105 safe_allocate(this%force(dim, system_np))
108 safe_allocate(this%partner_e_field(1:dim, 1:system_np))
109 this%partner_e_field =
m_zero
110 safe_allocate(this%partner_b_field(1:dim, 1:system_np))
111 this%partner_b_field =
m_zero
113 this%system_charge => system_charge
114 this%system_pos => system_pos
115 this%system_vel => system_vel
122 class(lorentz_force_t),
intent(inout) :: this
129 assert(this%dim == 3)
130 assert(.not. this%intra_interaction)
132 do ip = 1, this%system_np
133 this%force(1, ip) = this%partner_e_field(1, ip) + &
134 this%system_vel(2, ip)*this%partner_b_field(3, ip) - this%system_vel(3, ip)*this%partner_b_field(2, ip)
136 this%force(2, ip) = this%partner_e_field(2, ip) + &
137 this%system_vel(3, ip)*this%partner_b_field(1, ip) - this%system_vel(1, ip)*this%partner_b_field(3, ip)
139 this%force(3, ip) = this%partner_e_field(3, ip) + &
140 this%system_vel(1, ip)*this%partner_b_field(2, ip) - this%system_vel(2, ip)*this%partner_b_field(1, ip)
142 this%force(1:3, ip) = this%force(1:3, ip)*this%system_charge(ip)
153 real(real64) :: power
160 do ip = 1, this%system_np
161 power = power - dot_product(this%system_vel(1:3,ip), this%force(1:3,ip))
181 nullify(this%system_charge)
182 nullify(this%system_pos)
183 nullify(this%system_vel)
184 safe_deallocate_a(this%force)
185 safe_deallocate_a(this%partner_e_field)
186 safe_deallocate_a(this%partner_b_field)
real(real64), parameter, public m_zero
This module defines the abstract interaction_t class, and some auxiliary classes for interactions.
subroutine, public interaction_end(this)
This module defines classes and functions for interaction partners.
subroutine lorentz_force_calculate_energy(this)
class(lorentz_force_t) function, pointer lorentz_force_constructor(partner)
subroutine lorentz_force_finalize(this)
subroutine lorentz_force_init(this, dim, system_np, system_charge, system_pos, system_vel, namespace)
subroutine lorentz_force_calculate(this)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
This module defines the quantity_t class and the IDs for quantities, which can be exposed by a system...
Lorenz force between a systems of particles and an electromagnetic field.