diff --git a/CMakeLists.txt b/CMakeLists.txt index c85e9a63..d9ab7df4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.18) -ENABLE_LANGUAGE(Fortran) +enable_language (CXX Fortran) project(semba-fdtd Fortran) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -64,8 +64,9 @@ if (CompileExecutable) "src_main_pub/version.F90" "src_wires_pub/wires_types.F90" "src_wires_pub/wires.F90" + "src_wires_pub/wires_mtln.F90" ) - target_link_libraries(semba-fdtd semba-types smbjson) + target_link_libraries(semba-fdtd semba-types smbjson mtlnsolver ngspice_interface ${NGSPICE_LIB} stdc++) include_directories(${CMAKE_BINARY_DIR}/mod) endif() diff --git a/external/googletest b/external/googletest index c4fec745..6a593823 160000 --- a/external/googletest +++ b/external/googletest @@ -1 +1 @@ -Subproject commit c4fec74514a59e4501540a77703606910cb0ee60 +Subproject commit 6a5938233b6519ba99ddb7c7314d45d3fa877969 diff --git a/external/ngspice b/external/ngspice index 03ec21c1..902a62d2 160000 --- a/external/ngspice +++ b/external/ngspice @@ -1 +1 @@ -Subproject commit 03ec21c1a650f62301a748c92f25de65e6baedd7 +Subproject commit 902a62d2f442a1d8322ae4fcad35c143c7a14561 diff --git a/src_json_parser/smbjson.F90 b/src_json_parser/smbjson.F90 index ebe41c55..b5d2180c 100644 --- a/src_json_parser/smbjson.F90 +++ b/src_json_parser/smbjson.F90 @@ -1912,7 +1912,7 @@ function readMTLNCable(j_cable, is_read) result(res) end if res%step_size = buildStepSize(j_cable) - res%segment_relative_positions = mapSegmentsToGridCoordinates(j_cable) + res%external_field_segments = mapSegmentsToGridCoordinates(j_cable) ! write(*,*) 'id: ', this%getIntAt(j_cable, J_MATERIAL_ID, found) material = this%matTable%getId(this%getIntAt(j_cable, J_MATERIAL_ID, found)) if (.not. found) & @@ -2075,7 +2075,7 @@ subroutine assignPULProperties(res, mat, n) function mapSegmentsToGridCoordinates(j_cable) result(res) type(json_value), pointer :: j_cable - type(segment_relative_position_t), dimension(:), allocatable :: res + type(external_field_segment_t), dimension(:), allocatable :: res integer, dimension(:), allocatable :: elemIds type(polyline_t) :: p_line @@ -2104,14 +2104,16 @@ function mapSegmentsToGridCoordinates(j_cable) result(res) function mapNegativeSegment(c1, c2) result(res) type(coordinate_t), intent(in) :: c1, c2 - type(segment_relative_position_t) :: curr_pos + type(external_field_segment_t) :: curr_pos integer :: axis, i, n_segments - type(segment_relative_position_t), dimension(:), allocatable :: res + type(external_field_segment_t), dimension(:), allocatable :: res axis = findDirection(c2-c1) n_segments = abs(ceiling(c2%position(axis)) - floor(c1%position(axis))) allocate(res(n_segments)) curr_pos%position = [(c1%position(i), i = 1, 3)] + curr_pos%Efield_main2wire => null() + curr_pos%Efield_wire2main => null() res = [(curr_pos, i = 1, n_segments)] res(:)%position(axis) = [(res(i)%position(axis) - i, i = 1, n_segments)] @@ -2120,15 +2122,17 @@ function mapNegativeSegment(c1, c2) result(res) function mapPositiveSegment(c1, c2) result(res) type(coordinate_t), intent(in) :: c1, c2 - type(segment_relative_position_t) :: curr_pos + type(external_field_segment_t) :: curr_pos integer :: axis, orientation, i, n_segments - type(segment_relative_position_t), dimension(:), allocatable :: res + type(external_field_segment_t), dimension(:), allocatable :: res axis = findDirection(c2-c1) n_segments = abs(floor(c2%position(axis)) - ceiling(c1%position(axis))) allocate(res(n_segments)) curr_pos%position = [(c1%position(i), i = 1, 3)] + curr_pos%Efield_main2wire => null() + curr_pos%Efield_wire2main => null() res = [(curr_pos, i = 1, n_segments)] res(:)%position(axis) = [(res(i)%position(axis) + (i-1), i = 1, n_segments)] diff --git a/src_main_pub/timestepping.F90 b/src_main_pub/timestepping.F90 index 44c3e81f..b24074a4 100755 --- a/src_main_pub/timestepping.F90 +++ b/src_main_pub/timestepping.F90 @@ -1367,7 +1367,7 @@ subroutine launch_simulation(sgg,sggMtag,sggMiNo,sggMiEx,sggMiEy,sggMiEz,sggMiHx endif #endif #ifdef CompileWithWires_mtln - if (thereAre%MTLNbundles) call AdvanceWiresE_mtln(sgg,Ex,Ey,Ez,Idxe,Idye,Idze,Idxh,Idyh,Idzh,eps0,mu0,mtln_solver) + if (thereAre%MTLNbundles) call AdvanceWiresE_mtln(sgg, Idxe,Idye,Idze,Idxh,Idyh,Idzh,eps0,mu0,mtln_solver) #endif If (Thereare%PMLbodies) then !waveport absorbers call AdvancePMLbodyE diff --git a/src_mtln/mtl.F90 b/src_mtln/mtl.F90 index e1daa8f1..c4c461d5 100644 --- a/src_mtln/mtl.F90 +++ b/src_mtln/mtl.F90 @@ -3,7 +3,7 @@ module mtl_mod ! use NFDETypes use utils_mod use dispersive_mod - use mtln_types_mod, only: segment_relative_position_t + use mtln_types_mod, only: external_field_segment_t implicit none @@ -20,7 +20,7 @@ module mtl_mod integer :: conductor_in_parent type(transfer_impedance_per_meter_t) :: transfer_impedance - type(segment_relative_position_t), allocatable, dimension(:) :: segment_relative_positions + type(external_field_segment_t), allocatable, dimension(:) :: external_field_segments contains procedure :: setTimeStep @@ -84,7 +84,7 @@ function mtlHomogeneous(lpul, cpul, rpul, gpul, & step_size, name, & dt, parent_name, conductor_in_parent, & transfer_impedance, & - segment_relative_positions) result(res) + external_field_segments) result(res) type(mtl_t) :: res real, intent(in), dimension(:,:) :: lpul, cpul, rpul, gpul real, intent(in), dimension(:) :: step_size @@ -95,7 +95,7 @@ function mtlHomogeneous(lpul, cpul, rpul, gpul, & character(len=*), intent(in), optional :: parent_name integer, intent(in), optional :: conductor_in_parent type(transfer_impedance_per_meter_t), intent(in), optional :: transfer_impedance - type(segment_relative_position_t), intent(in), dimension(:), optional :: segment_relative_positions + type(external_field_segment_t), intent(in), dimension(:), optional :: external_field_segments res%name = name res%step_size = step_size @@ -130,15 +130,16 @@ function mtlHomogeneous(lpul, cpul, rpul, gpul, & res%transfer_impedance = transfer_impedance end if - if (present(segment_relative_positions)) then - res%segment_relative_positions = segment_relative_positions + if (present(external_field_segments)) then + res%external_field_segments = external_field_segments end if end function function mtlInhomogeneous(lpul, cpul, rpul, gpul, & step_size, name, & dt, parent_name, conductor_in_parent, & - transfer_impedance) result(res) + transfer_impedance, & + external_field_segments) result(res) type(mtl_t) :: res real, intent(in), dimension(:,:,:) :: lpul, cpul, rpul, gpul real, intent(in), dimension(:) :: step_size @@ -148,6 +149,7 @@ function mtlInhomogeneous(lpul, cpul, rpul, gpul, & character(len=*), intent(in), optional :: parent_name integer, intent(in), optional :: conductor_in_parent type(transfer_impedance_per_meter_t), intent(in), optional :: transfer_impedance + type(external_field_segment_t), intent(in), dimension(:), optional :: external_field_segments res%name = name res%step_size = step_size @@ -181,6 +183,10 @@ function mtlInhomogeneous(lpul, cpul, rpul, gpul, & res%transfer_impedance = transfer_impedance end if + if (present(external_field_segments)) then + res%external_field_segments = external_field_segments + end if + end function subroutine initDirections(this) diff --git a/src_mtln/mtl_bundle.F90 b/src_mtln/mtl_bundle.F90 index c8f9afe8..d23f7bb9 100644 --- a/src_mtln/mtl_bundle.F90 +++ b/src_mtln/mtl_bundle.F90 @@ -21,7 +21,7 @@ module mtl_bundle_mod real, dimension(:,:,:), allocatable :: v_term, i_term real, dimension(:,:,:), allocatable :: v_diff, i_diff - type(segment_relative_position_t), dimension(:), allocatable :: segment_relative_positions + type(external_field_segment_t), dimension(:), allocatable :: external_field_segments contains @@ -37,7 +37,6 @@ module mtl_bundle_mod procedure :: advanceCurrent => bundle_advanceCurrent procedure :: addTransferImpedance => bundle_addTransferImpedance ! procedure :: setConnectorTransferImpedance - procedure :: setExternalCurrent => bundle_setExternalCurrent procedure :: setExternalVoltage => bundle_setExternalVoltage procedure :: updateExternalCurrent => bundle_updateExternalCurrent @@ -64,7 +63,7 @@ function mtldCtor(levels, name) result(res) res%dt = levels(1)%lines(1)%dt res%step_size = levels(1)%lines(1)%step_size res%number_of_divisions = size(res%step_size,1) - res%segment_relative_positions = levels(1)%lines(1)%segment_relative_positions + res%external_field_segments = levels(1)%lines(1)%external_field_segments call res%initialAllocation() call res%mergePULMatrices(levels) call res%mergeDispersiveMatrices(levels) @@ -309,23 +308,12 @@ subroutine bundle_advanceCurrent(this) ! call this%transfer_impedance%updatePhi(i_prev, i_now) end subroutine - subroutine bundle_setExternalCurrent(this, current) + subroutine bundle_setExternalVoltage(this) class(mtl_bundle_t) :: this - real, dimension(:), intent(in) :: current - this%i(1,:) = current(:) - end subroutine - - subroutine bundle_setExternalVoltage(this, voltage) - class(mtl_bundle_t) :: this - real, dimension(:,:,:), intent(in) :: voltage - ! real, dimension(:), intent(in) :: voltage - integer, dimension(:), allocatable :: position integer :: i do i = 1, size(this%v,2) - position = this%segment_relative_positions(i)%position - this%v(1, i) = voltage(position(1), position(2), position(3)) + this%v(1, i) = this%external_field_segments(i)%Efield_main2wire * this%step_size(i) end do - ! this%v(1,:) = voltage(:) end subroutine subroutine bundle_updateExternalCurrent(this, current) @@ -335,7 +323,7 @@ subroutine bundle_updateExternalCurrent(this, current) integer, dimension(:), allocatable :: position integer :: i do i = 1, size(this%i,2) - position = this%segment_relative_positions(i)%position + position = this%external_field_segments(i)%position current(position(1), position(2), position(3)) = this%i(1,i) end do ! current(:) = this%i(1,:) diff --git a/src_mtln/mtln_solver.F90 b/src_mtln/mtln_solver.F90 index b8cf1d47..5bd2ece1 100644 --- a/src_mtln/mtln_solver.F90 +++ b/src_mtln/mtln_solver.F90 @@ -70,15 +70,11 @@ subroutine initNodes(this) end do end subroutine - subroutine mtln_step(this, currents, voltages) + subroutine mtln_step(this) class(mtln_t) :: this - ! real, dimension(:,:), intent(inout) :: currents - ! real, dimension(:,:), intent(in) :: voltages - real, dimension(:,:,:), intent(inout) :: currents - real, dimension(:,:,:), intent(in) :: voltages integer :: i - call this%setExternalVoltage(voltages) + call this%setExternalVoltage() call this%advanceBundlesVoltage() call this%advanceNWVoltage() @@ -87,7 +83,7 @@ subroutine mtln_step(this, currents, voltages) call this%advanceTime() call this%updateProbes() - call this%updateExternalCurrent(currents) + ! call this%updateExternalCurrent() end subroutine subroutine step_alone(this) @@ -104,14 +100,11 @@ subroutine step_alone(this) end subroutine - subroutine setExternalVoltage(this, voltages) + subroutine setExternalVoltage(this) class(mtln_t) :: this - ! real, dimension(:,:), intent(in) :: voltages - real, dimension(:,:,:), intent(in) :: voltages integer :: i do i = 1, this%number_of_bundles - call this%bundles(i)%setExternalVoltage(voltages) - ! call this%bundles(i)%setExternalVoltage(voltages(i,:)) + call this%bundles(i)%setExternalVoltage() end do end subroutine diff --git a/src_mtln/mtln_types.F90 b/src_mtln/mtln_types.F90 index b58ec834..a9103b6f 100644 --- a/src_mtln/mtln_types.F90 +++ b/src_mtln/mtln_types.F90 @@ -28,14 +28,14 @@ module mtln_types_mod integer, parameter :: DIRECTION_Z_POS = 3 integer, parameter :: DIRECTION_Z_NEG = -3 - type :: segment_relative_position_t + type :: external_field_segment_t integer, dimension(3) ::position integer :: direction - REAL (KIND=RKIND) , pointer :: Efield_wire2main,Efield_main2wire !sggmtln + real (kind=rkind) , pointer :: Efield_wire2main,Efield_main2wire !sggmtln contains private - procedure :: segment_relative_positions_eq - generic, public :: operator(==) => segment_relative_positions_eq + procedure :: external_field_segments_eq + generic, public :: operator(==) => external_field_segments_eq end type type :: termination_t @@ -120,7 +120,7 @@ module mtln_types_mod integer :: conductor_in_parent = -1 type(connector_t), pointer :: initial_connector => null() type(connector_t), pointer :: end_connector => null() - type(segment_relative_position_t), allocatable, dimension(:) :: segment_relative_positions + type(external_field_segment_t), allocatable, dimension(:) :: external_field_segments contains private @@ -184,7 +184,7 @@ recursive elemental logical function cable_eq(a,b) cable_eq = cable_eq .and. all(a%step_size == b%step_size) cable_eq = cable_eq .and. (a%transfer_impedance == b%transfer_impedance) cable_eq = cable_eq .and. (a%conductor_in_parent == b%conductor_in_parent) - cable_eq = cable_eq .and. all(a%segment_relative_positions == b%segment_relative_positions) + cable_eq = cable_eq .and. all(a%external_field_segments == b%external_field_segments) if (.not. cable_eq) then @@ -307,11 +307,31 @@ elemental logical function terminal_network_eq(a,b) all(a%connections == b%connections) end function - elemental logical function segment_relative_positions_eq(a,b) - class(segment_relative_position_t), intent(in) :: a,b - segment_relative_positions_eq = & + elemental logical function external_field_segments_eq(a,b) + class(external_field_segment_t), intent(in) :: a,b + external_field_segments_eq = & all(a%position == b%position) .and. & a%direction == b%direction + + if (.not. associated(a%Efield_main2wire) .and. .not. associated(b%Efield_main2wire)) then + external_field_segments_eq = external_field_segments_eq .and. .true. + else if ((associated(a%Efield_main2wire) .and. .not. associated(b%Efield_main2wire)) .or. & + (.not. associated(a%Efield_main2wire) .and. associated(b%Efield_main2wire))) then + external_field_segments_eq = external_field_segments_eq .and. .false. + else + external_field_segments_eq = external_field_segments_eq .and. (a%Efield_main2wire == b%Efield_main2wire) + end if + + if (.not. associated(a%Efield_wire2main) .and. .not. associated(b%Efield_wire2main)) then + external_field_segments_eq = external_field_segments_eq .and. .true. + else if ((associated(a%Efield_wire2main) .and. .not. associated(b%Efield_wire2main)) .or. & + (.not. associated(a%Efield_wire2main) .and. associated(b%Efield_wire2main))) then + external_field_segments_eq = external_field_segments_eq .and. .false. + else + external_field_segments_eq = external_field_segments_eq .and. (a%Efield_wire2main == b%Efield_wire2main) + end if + + end function subroutine terminal_connection_add_node(this, node) diff --git a/src_mtln/preprocess.F90 b/src_mtln/preprocess.F90 index c7b5e3dc..b84852af 100644 --- a/src_mtln/preprocess.F90 +++ b/src_mtln/preprocess.F90 @@ -211,7 +211,7 @@ function buildLineFromCable(cable) result(res) parent_name = parent_name, & conductor_in_parent = conductor_in_parent, & transfer_impedance = cable%transfer_impedance, & - segment_relative_positions = cable%segment_relative_positions) + external_field_segments = cable%external_field_segments) if (associated(cable%initial_connector)) call addConnector(res, cable%initial_connector, 0) if (associated(cable%end_connector)) call addConnector(res, cable%initial_connector, size(res%rpul,1)) diff --git a/src_wires_pub/wires_mtln.F90 b/src_wires_pub/wires_mtln.F90 index 451fed4f..79061094 100644 --- a/src_wires_pub/wires_mtln.F90 +++ b/src_wires_pub/wires_mtln.F90 @@ -7,22 +7,19 @@ module Wire_bundles_mtln_mod use report use fdetypes -!!! use mtln_solver_mod , mtln_solver_t => mtln_t -!!! + implicit none - -!!!variables globales del modulo - REAL (KIND=RKIND_wires) :: eps0,mu0 -!!! + real (kind=rkind_wires) :: eps0, mu0 private - public InitWires_mtln,AdvanceWiresE_mtln + public InitWires_mtln, AdvanceWiresE_mtln contains - subroutine InitWires_mtln(sgg,Ex,Ey,Ez,mtln_wir,thereAreMTLNbundles) + + subroutine InitWires_mtln(sgg,Ex,Ey,Ez,mtln_solver,thereAreMTLNbundles) type (SGGFDTDINFO), intent(IN), target :: sgg REAL (KIND=RKIND), intent(inout), target :: & Ex(sgg%Alloc(iEx)%XI : sgg%Alloc(iEx)%XE, & @@ -34,111 +31,84 @@ subroutine InitWires_mtln(sgg,Ex,Ey,Ez,mtln_wir,thereAreMTLNbundles) Ez(sgg%Alloc(iEz)%XI : sgg%Alloc(iEz)%XE, & sgg%Alloc(iEz)%YI : sgg%Alloc(iEz)%YE, & sgg%Alloc(iEz)%ZI : sgg%Alloc(iEz)%ZE) - class(mtln_solver_t) :: mtln_wir - integer (kind=4) :: i, j, k,direction,m,n,number_of_segments - logical :: thereAreMTLNbundles - if (MTLN_WIR%NUMBER_OF_BUNDLES>=1) then - thereAreMTLNbundles=.true. - else - thereAreMTLNbundles=.false. - return - endif - do m=1,MTLN_WIR%NUMBER_OF_BUNDLES - number_of_segments=ubound(MTLN_WIR%bundles(m)%SEGMENT_RELATIVE_POSITIONS,1) - do n=1,number_of_segments - i = MTLN_WIR%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%position(1) - j = MTLN_WIR%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%position(2) - k = MTLN_WIR%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%position(3) - direction=MTLN_WIR%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%direction - select case (abs(direction)) - case(1) - mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%Efield_wire2main => Ex(I,J,K) - mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%Efield_main2wire => Ex(I,J,K) - case(2) - mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%Efield_wire2main => Ey(I,J,K) - mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%Efield_main2wire => Ey(I,J,K) - case(3) - mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%Efield_wire2main => Ez(I,J,K) - mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%Efield_main2wire => Ez(I,J,K) - end select - + class(mtln_solver_t) :: mtln_solver + logical :: thereAreMTLNbundles + + if (mtln_solver%number_of_bundles>=1) then + thereAreMTLNbundles=.true. + else + thereAreMTLNbundles=.false. + return + endif + + block + integer (kind=4) :: i, j, k, m, n + do m = 1, mtln_solver%NUMBER_OF_BUNDLES + do n = 1, ubound(mtln_solver%bundles(m)%external_field_segments,1) + call readGridIndices(i, j, k, mtln_solver%bundles(m)%external_field_segments(n)) + select case (abs(mtln_solver%bundles(m)%external_field_segments(n)%direction)) + case(1) + mtln_solver%bundles(m)%external_field_segments(n)%Efield_wire2main => Ex(i, j, k) + mtln_solver%bundles(m)%external_field_segments(n)%Efield_main2wire => Ex(i, j, k) + case(2) + mtln_solver%bundles(m)%external_field_segments(n)%Efield_wire2main => Ey(i, j, k) + mtln_solver%bundles(m)%external_field_segments(n)%Efield_main2wire => Ey(i, j, k) + case(3) + mtln_solver%bundles(m)%external_field_segments(n)%Efield_wire2main => Ez(i, j, k) + mtln_solver%bundles(m)%external_field_segments(n)%Efield_main2wire => Ez(i, j, k) + end select + end do - end do - return - endsubroutine InitWires_mtln + end do + end block + + end subroutine InitWires_mtln - subroutine AdvanceWiresE_mtln(sgg,Ex,Ey,Ez,Idxe,Idye,Idze,Idxh,Idyh,Idzh,eps00,mu00,mtln_wir) - class(mtln_solver_t) :: mtln_wir + subroutine AdvanceWiresE_mtln(sgg,Idxh, Idyh, Idzh, eps00,mu00,mtln_solver) + class(mtln_solver_t) :: mtln_solver type (SGGFDTDINFO), intent(IN), target :: sgg - REAL (KIND=RKIND), intent(inout), target :: & - Ex(sgg%Alloc(iEx)%XI : sgg%Alloc(iEx)%XE, & - sgg%Alloc(iEx)%YI : sgg%Alloc(iEx)%YE, & - sgg%Alloc(iEx)%ZI : sgg%Alloc(iEx)%ZE), & - Ey(sgg%Alloc(iEy)%XI : sgg%Alloc(iEy)%XE, & - sgg%Alloc(iEy)%YI : sgg%Alloc(iEy)%YE, & - sgg%Alloc(iEy)%ZI : sgg%Alloc(iEy)%ZE), & - Ez(sgg%Alloc(iEz)%XI : sgg%Alloc(iEz)%XE, & - sgg%Alloc(iEz)%YI : sgg%Alloc(iEz)%YE, & - sgg%Alloc(iEz)%ZI : sgg%Alloc(iEz)%ZE) - real (kind=RKIND), dimension (:), intent(in) :: & - Idxe(sgg%ALLOC(iHx)%XI : sgg%ALLOC(iHx)%XE),& - Idye(sgg%ALLOC(iHy)%YI : sgg%ALLOC(iHy)%YE),& - Idze(sgg%ALLOC(iHz)%ZI : sgg%ALLOC(iHz)%ZE),& + real (kind=RKIND), dimension (:), intent(in) :: & Idxh(sgg%ALLOC(iEx)%XI : sgg%ALLOC(iEx)%XE),& Idyh(sgg%ALLOC(iEy)%YI : sgg%ALLOC(iEy)%YE),& - Idzh(sgg%ALLOC(iEz)%ZI : sgg%ALLOC(iEz)%ZE) - real(KIND=RKIND) , dimension(:,:,:), allocatable :: currents - real(KIND=RKIND) , dimension(:,:,:), allocatable :: voltages - real(KIND=RKIND) :: cte,eps00,mu00 - integer (kind=4) :: i, j, k,direction,m,n,number_of_segments - REAL (KIND=RKIND),pointer:: punt - eps0=eps00; mu0=mu00; !chapuz para convertir la variables de paso en globales !necesario para permittivity scaling - - do m=1,MTLN_WIR%NUMBER_OF_BUNDLES - number_of_segments=ubound(mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONS,1) - do n=1,number_of_segments - i = mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%position(1) - j = mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%position(2) - k = mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%position(3) - direction=MTLN_WIR%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%direction - punt => mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%Efield_wire2main - select case (abs(direction)) - case(1) - ! voltages(i,j,k) = sign(punt,real(direction,kind=rkind)) / Idxe(i) - case(2) - ! voltages(i,j,k) = sign(punt,real(direction,kind=rkind)) / Idye(j) - case(3) - ! voltages(i,j,k) = SIGN(punt,real(direction,kind=rkind)) / Idze(k) - end select - end do - end do - ! - ! call mtln_step(mtln_wir, currents, voltages) !!!AGB esto hay que tocarlo porque voltages y currents ya estan en punteros - ! - do m=1,mtln_wir%NUMBER_OF_BUNDLES - number_of_segments=1 !ubound(mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONS,1) - do n=1,number_of_segments - i =mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%position(1) - j =mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%position(2) - k =mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%position(3) - direction=MTLN_WIR%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%direction - punt => mtln_wir%bundles(m)%SEGMENT_RELATIVE_POSITIONs(n)%Efield_wire2main - select case (abs(direction)) - case(1) - cte=sgg%dt /eps0 *Idyh(j)*idzh(k) - ! punt = punt - sign(cte,real(direction,kind=rkind))*currents(I,J,K) - case(2) - cte=sgg%dt /eps0 *Idzh(k)*idxh(i) - ! punt = punt - sign(cte,real(direction,kind=rkind))*currents(I,J,K) - case(3) - cte=sgg%dt /eps0 *Idxh(i)*idyh(j) - ! punt =punt - sign(cte,real(direction,kind=rkind))*currents(I,J,K) - end select - !segmento%efield_wire2main = real(segmento%efield_wire2main,kind=rkind_wires) - segmento%cte5 * segmento%current - end do - end do - return + Idzh(sgg%ALLOC(iEz)%ZI : sgg%ALLOC(iEz)%ZE) + real(KIND=RKIND) :: cte, eps00, mu00 + integer (kind=4) :: i, j, k, direction, m, n + real (kind= rkind) :: current + real(kind = rkind), pointer :: punt + + eps0 = eps00 + mu0 = mu00 + + call mtln_solver%step() + + do m = 1, mtln_solver%number_of_bundles + do n = 1, ubound(mtln_solver%bundles(m)%external_field_segments,1) + call readGridIndices(i, j, k, mtln_solver%bundles(m)%external_field_segments(n)) + direction = mtln_solver%bundles(m)%external_field_segments(n)%direction + punt => mtln_solver%bundles(m)%external_field_segments(n)%Efield_wire2main + current = mtln_solver%bundles(m)%i(1, n) + select case (abs(direction)) + case(1) + cte = sgg%dt /eps0 *Idyh(j)*idzh(k) + case(2) + cte = sgg%dt /eps0 *Idzh(k)*idxh(i) + case(3) + cte = sgg%dt /eps0 *Idxh(i)*idyh(j) + end select + punt = punt - sign(cte,real(direction,kind=rkind)) * current + end do + end do end subroutine AdvanceWiresE_mtln + + subroutine readGridIndices(i, j, k, field_segment) + type(external_field_segment_t), intent(in) :: field_segment + integer, intent(inout) :: i, j, k + i = field_segment%position(1) + j = field_segment%position(2) + k = field_segment%position(3) + end subroutine + + end module Wire_bundles_mtln_mod diff --git a/test/mtln/test_Paul.F90 b/test/mtln/test_Paul.F90 index 081b2891..05c46952 100644 --- a/test/mtln/test_Paul.F90 +++ b/test/mtln/test_Paul.F90 @@ -749,7 +749,7 @@ integer function test_coaxial_line_paul_8_6_square() bind(C) result(error_cnt) character(20) :: charR, charL, charC, lineC integer :: i - type(segment_relative_position_t), dimension(100) :: segment_positions + type(external_field_segment_t), dimension(100) :: external_field_segments error_cnt = 0 cable%name = "wire0" @@ -758,10 +758,12 @@ integer function test_coaxial_line_paul_8_6_square() bind(C) result(error_cnt) cable%resistance_per_meter = rpul cable%capacitance_per_meter = cpul do i = 1, 100 - segment_positions(i)%position = (/i, 1, 1/) - segment_positions(i)%direction = 1 + external_field_segments(i)%position = (/i, 1, 1/) + external_field_segments(i)%direction = 1 + external_field_segments(i)%Efield_main2wire => null() + external_field_segments(i)%Efield_wire2main => null() end do - cable%segment_relative_positions = segment_positions + cable%external_field_segments = external_field_segments cable%step_size = [(4.0, i = 1, 100)] parsed%time_step = 2e-8 diff --git a/test/mtln/test_mtl_bundle.F90 b/test/mtln/test_mtl_bundle.F90 index d4ceb5c8..8e66ea58 100644 --- a/test/mtln/test_mtl_bundle.F90 +++ b/test/mtln/test_mtl_bundle.F90 @@ -14,22 +14,24 @@ integer function test_mtl_bundle_init() bind(C) result(error_cnt) real, dimension(5) :: step_size = [20.0, 20.0, 20.0, 20.0, 20.0] - type(segment_relative_position_t), dimension(5) :: segment_positions + type(external_field_segment_t), dimension(5) :: external_field_segments error_cnt = 0 block integer :: i do i = 1, 5 - segment_positions(i)%position = (/i, 1, 1/) - segment_positions(i)%direction = 1 + external_field_segments(i)%position = (/i, 1, 1/) + external_field_segments(i)%direction = 1 + external_field_segments(i)%Efield_main2wire => null() + external_field_segments(i)%Efield_wire2main => null() end do end block - mtl_out = mtl_t(l1, c1, r1, g1, step_size, "line_out", segment_relative_positions = segment_positions) + mtl_out = mtl_t(l1, c1, r1, g1, step_size, "line_out", external_field_segments = external_field_segments) mtl_in = mtl_t(l1, c1, r1, g1, step_size, "line_in", & parent_name = "line_out", & conductor_in_parent = 1, & - segment_relative_positions = segment_positions) + external_field_segments = external_field_segments) allocate(levels(1)%lines(1)) allocate(levels(2)%lines(1)) diff --git a/test/mtln/testingTools.F90 b/test/mtln/testingTools.F90 index b3c14007..6e418af1 100644 --- a/test/mtln/testingTools.F90 +++ b/test/mtln/testingTools.F90 @@ -60,7 +60,7 @@ type(mtl_t) function buildLineWithNConductors(n,name, parent_name, conductor_in_ integer, intent(in), optional :: conductor_in_parent real, allocatable, dimension(:,:) :: lpul, cpul, rpul, gpul real, dimension(5) :: step_size = [20.0, 20.0, 20.0, 20.0, 20.0] - type(segment_relative_position_t), dimension(5) :: segment_positions + type(external_field_segment_t), dimension(5) :: external_field_segments integer :: i,j allocate(lpul(n,n), source = 0.0) @@ -69,8 +69,10 @@ type(mtl_t) function buildLineWithNConductors(n,name, parent_name, conductor_in_ allocate(rpul(n,n), source = 0.0) do i = 1, 5 - segment_positions(i)%position =(/i,1,1/) - segment_positions(i)%direction = DIRECTION_X_POS + external_field_segments(i)%position =(/i,1,1/) + external_field_segments(i)%direction = DIRECTION_X_POS + external_field_segments(i)%Efield_main2wire => null() + external_field_segments(i)%Efield_wire2main => null() end do do i = 1, n @@ -88,20 +90,20 @@ type(mtl_t) function buildLineWithNConductors(n,name, parent_name, conductor_in_ end do if (present(dt) .and. .not.present(parent_name)) then res = mtl_t(lpul, cpul, rpul, gpul, step_size, name, dt = dt, & - segment_relative_positions = segment_positions) + external_field_segments = external_field_segments) else if (.not.present(dt) .and. present(parent_name) ) then res = mtl_t(lpul, cpul, rpul, gpul, step_size, name, & parent_name= parent_name, & conductor_in_parent=conductor_in_parent, & - segment_relative_positions = segment_positions) + external_field_segments = external_field_segments) else if (present(dt) .and. present(parent_name) ) then res = mtl_t(lpul, cpul, rpul, gpul, step_size, name, & parent_name= parent_name, & conductor_in_parent=conductor_in_parent, & - dt = dt, segment_relative_positions = segment_positions) + dt = dt, external_field_segments = external_field_segments) else res = mtl_t(lpul, cpul, rpul, gpul, step_size, name, & - segment_relative_positions = segment_positions) + external_field_segments = external_field_segments) end if end function diff --git a/test/smbjson/test_read_mtln.F90 b/test/smbjson/test_read_mtln.F90 index 05d16bd2..e81f046f 100644 --- a/test/smbjson/test_read_mtln.F90 +++ b/test/smbjson/test_read_mtln.F90 @@ -333,10 +333,12 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(1)%step_size(9)) expected%mtln%cables(1)%step_size = [(0.1, i = 1, 9)] - allocate(expected%mtln%cables(1)%segment_relative_positions(9)) + allocate(expected%mtln%cables(1)%external_field_segments(9)) do i = 1, 9 - expected%mtln%cables(1)%segment_relative_positions(i)%position = (/i,9,1/) - expected%mtln%cables(1)%segment_relative_positions(i)%direction = DIRECTION_X_POS + expected%mtln%cables(1)%external_field_segments(i)%position = (/i,9,1/) + expected%mtln%cables(1)%external_field_segments(i)%direction = DIRECTION_X_POS + expected%mtln%cables(1)%external_field_segments(i)%Efield_main2wire => null() + expected%mtln%cables(1)%external_field_segments(i)%Efield_wire2main => null() end do allocate(expected%mtln%cables(1)%transfer_impedance%poles(0)) @@ -360,10 +362,13 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(2)%step_size(9)) expected%mtln%cables(2)%step_size = [(0.1, i = 1, 9)] - allocate(expected%mtln%cables(2)%segment_relative_positions(9)) + allocate(expected%mtln%cables(2)%external_field_segments(9)) do i = 1, 9 - expected%mtln%cables(2)%segment_relative_positions(i)%position = (/i,9,1/) - expected%mtln%cables(2)%segment_relative_positions(i)%direction = DIRECTION_X_POS + expected%mtln%cables(2)%external_field_segments(i)%position = (/i,9,1/) + expected%mtln%cables(2)%external_field_segments(i)%direction = DIRECTION_X_POS + expected%mtln%cables(2)%external_field_segments(i)%Efield_main2wire => null() + expected%mtln%cables(2)%external_field_segments(i)%Efield_wire2main => null() + end do expected%mtln%cables(2)%transfer_impedance%direction = TRANSFER_IMPEDANCE_DIRECTION_INWARDS @@ -408,10 +413,13 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(3)%step_size(9)) expected%mtln%cables(3)%step_size = [(0.1, i = 1, 9)] - allocate(expected%mtln%cables(3)%segment_relative_positions(9)) + allocate(expected%mtln%cables(3)%external_field_segments(9)) do i = 1, 9 - expected%mtln%cables(3)%segment_relative_positions(i)%position = (/i,9,1/) - expected%mtln%cables(3)%segment_relative_positions(i)%direction = DIRECTION_X_POS + expected%mtln%cables(3)%external_field_segments(i)%position = (/i,9,1/) + expected%mtln%cables(3)%external_field_segments(i)%direction = DIRECTION_X_POS + expected%mtln%cables(3)%external_field_segments(i)%Efield_main2wire => null() + expected%mtln%cables(3)%external_field_segments(i)%Efield_wire2main => null() + end do @@ -442,10 +450,13 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(4)%step_size(8)) expected%mtln%cables(4)%step_size = [(0.1, i = 1, 8)] - allocate(expected%mtln%cables(4)%segment_relative_positions(8)) + allocate(expected%mtln%cables(4)%external_field_segments(8)) do i = 1, 8 - expected%mtln%cables(4)%segment_relative_positions(i)%position = (/9+i,9,1/) - expected%mtln%cables(4)%segment_relative_positions(i)%direction = DIRECTION_X_POS + expected%mtln%cables(4)%external_field_segments(i)%position = (/9+i,9,1/) + expected%mtln%cables(4)%external_field_segments(i)%direction = DIRECTION_X_POS + expected%mtln%cables(4)%external_field_segments(i)%Efield_main2wire => null() + expected%mtln%cables(4)%external_field_segments(i)%Efield_wire2main => null() + end do @@ -470,10 +481,13 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(5)%step_size(8)) expected%mtln%cables(5)%step_size = [(0.1, i = 1, 8)] - allocate(expected%mtln%cables(5)%segment_relative_positions(8)) + allocate(expected%mtln%cables(5)%external_field_segments(8)) do i = 1, 8 - expected%mtln%cables(5)%segment_relative_positions(i)%position = (/9+i,9,1/) - expected%mtln%cables(5)%segment_relative_positions(i)%direction = DIRECTION_X_POS + expected%mtln%cables(5)%external_field_segments(i)%position = (/9+i,9,1/) + expected%mtln%cables(5)%external_field_segments(i)%direction = DIRECTION_X_POS + expected%mtln%cables(5)%external_field_segments(i)%Efield_main2wire => null() + expected%mtln%cables(5)%external_field_segments(i)%Efield_wire2main => null() + end do @@ -507,10 +521,13 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(6)%step_size(8)) expected%mtln%cables(6)%step_size = [(0.1, i = 1, 8)] - allocate(expected%mtln%cables(6)%segment_relative_positions(8)) + allocate(expected%mtln%cables(6)%external_field_segments(8)) do i = 1, 8 - expected%mtln%cables(6)%segment_relative_positions(i)%position = (/9+i,9,1/) - expected%mtln%cables(6)%segment_relative_positions(i)%direction = DIRECTION_X_POS + expected%mtln%cables(6)%external_field_segments(i)%position = (/9+i,9,1/) + expected%mtln%cables(6)%external_field_segments(i)%direction = DIRECTION_X_POS + expected%mtln%cables(6)%external_field_segments(i)%Efield_main2wire => null() + expected%mtln%cables(6)%external_field_segments(i)%Efield_wire2main => null() + end do @@ -541,10 +558,13 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(7)%step_size(7)) expected%mtln%cables(7)%step_size = [(0.1, i = 1, 7)] - allocate(expected%mtln%cables(7)%segment_relative_positions(7)) + allocate(expected%mtln%cables(7)%external_field_segments(7)) do i = 1,7 - expected%mtln%cables(7)%segment_relative_positions(i)%position = (/10,9-i,1/) - expected%mtln%cables(7)%segment_relative_positions(i)%direction = DIRECTION_Y_NEG + expected%mtln%cables(7)%external_field_segments(i)%position = (/10,9-i,1/) + expected%mtln%cables(7)%external_field_segments(i)%direction = DIRECTION_Y_NEG + expected%mtln%cables(7)%external_field_segments(i)%Efield_main2wire => null() + expected%mtln%cables(7)%external_field_segments(i)%Efield_wire2main => null() + end do @@ -569,10 +589,13 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(8)%step_size(7)) expected%mtln%cables(8)%step_size = [(0.1, i = 1, 7)] - allocate(expected%mtln%cables(8)%segment_relative_positions(7)) + allocate(expected%mtln%cables(8)%external_field_segments(7)) do i = 1,7 - expected%mtln%cables(8)%segment_relative_positions(i)%position = (/10,9-i,1/) - expected%mtln%cables(8)%segment_relative_positions(i)%direction = DIRECTION_Y_NEG + expected%mtln%cables(8)%external_field_segments(i)%position = (/10,9-i,1/) + expected%mtln%cables(8)%external_field_segments(i)%direction = DIRECTION_Y_NEG + expected%mtln%cables(8)%external_field_segments(i)%Efield_main2wire => null() + expected%mtln%cables(8)%external_field_segments(i)%Efield_wire2main => null() + end do expected%mtln%cables(8)%transfer_impedance%direction = TRANSFER_IMPEDANCE_DIRECTION_INWARDS @@ -612,10 +635,13 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(9)%step_size(7)) expected%mtln%cables(9)%step_size = [(0.1, i = 1, 7)] - allocate(expected%mtln%cables(9)%segment_relative_positions(7)) + allocate(expected%mtln%cables(9)%external_field_segments(7)) do i = 1,7 - expected%mtln%cables(9)%segment_relative_positions(i)%position = (/10,9-i,1/) - expected%mtln%cables(9)%segment_relative_positions(i)%direction = DIRECTION_Y_NEG + expected%mtln%cables(9)%external_field_segments(i)%position = (/10,9-i,1/) + expected%mtln%cables(9)%external_field_segments(i)%direction = DIRECTION_Y_NEG + expected%mtln%cables(9)%external_field_segments(i)%Efield_main2wire => null() + expected%mtln%cables(9)%external_field_segments(i)%Efield_wire2main => null() + end do expected%mtln%cables(9)%transfer_impedance%direction = TRANSFER_IMPEDANCE_DIRECTION_INWARDS diff --git a/test/smbjson/test_read_shieldedPair.F90 b/test/smbjson/test_read_shieldedPair.F90 index 631ba3c6..00dac146 100644 --- a/test/smbjson/test_read_shieldedPair.F90 +++ b/test/smbjson/test_read_shieldedPair.F90 @@ -148,10 +148,10 @@ function expectedProblemDescription() result (expected) expected%mtln%cables(2)%conductance_per_meter = reshape(source=[0.0], shape=[1,1]) allocate(expected%mtln%cables(2)%step_size(18)) expected%mtln%cables(2)%step_size = [(0.03, i = 1, 18)] - allocate(expected%mtln%cables(2)%segment_relative_positions(18)) + allocate(expected%mtln%cables(2)%external_field_segments(18)) do i = 1, 18 - expected%mtln%cables(2)%segment_relative_positions(i)%position = (/1,1,i/) - expected%mtln%cables(2)%segment_relative_positions(i)%direction = DIRECTION_Z_POS + expected%mtln%cables(2)%external_field_segments(i)%position = (/1,1,i/) + expected%mtln%cables(2)%external_field_segments(i)%direction = DIRECTION_Z_POS end do allocate(expected%mtln%cables(2)%transfer_impedance%poles(0)) @@ -178,10 +178,10 @@ function expectedProblemDescription() result (expected) allocate(expected%mtln%cables(1)%step_size(18)) expected%mtln%cables(1)%step_size = [(0.03, i = 1, 18)] - allocate(expected%mtln%cables(1)%segment_relative_positions(18)) + allocate(expected%mtln%cables(1)%external_field_segments(18)) do i = 1, 18 - expected%mtln%cables(1)%segment_relative_positions(i)%position = (/1,1,i/) - expected%mtln%cables(1)%segment_relative_positions(i)%direction = DIRECTION_Z_POS + expected%mtln%cables(1)%external_field_segments(i)%position = (/1,1,i/) + expected%mtln%cables(1)%external_field_segments(i)%direction = DIRECTION_Z_POS end do expected%mtln%cables(1)%transfer_impedance%direction = TRANSFER_IMPEDANCE_DIRECTION_INWARDS expected%mtln%cables(1)%transfer_impedance%resistive_term = 0.0