Blame view

SRC/CREATE_SPICE_CIRCUIT_MODEL/write_spice_dc_resistances.F90 4.35 KB
fe64b32b   Chris Smartt   Update file heade...
1
2
!
! This file is part of SACAMOS, State of the Art CAble MOdels for Spice. 
886c558b   Steve Greedy   SACAMOS Public Re...
3
4
5
! It was developed by the University of Nottingham and the Netherlands Aerospace 
! Centre (NLR) for ESA under contract number 4000112765/14/NL/HK.
! 
fe64b32b   Chris Smartt   Update file heade...
6
! Copyright (C) 2016-2018 University of Nottingham
886c558b   Steve Greedy   SACAMOS Public Re...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
! 
! SACAMOS is free software: you can redistribute it and/or modify it under the 
! terms of the GNU General Public License as published by the Free Software 
! Foundation, either version 3 of the License, or (at your option) any later 
! version.
! 
! SACAMOS is distributed in the hope that it will be useful, but 
! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
! or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
! for more details.
! 
! A copy of the GNU General Public License version 3 can be found in the 
! file GNU_GPL_v3 in the root or at <http://www.gnu.org/licenses/>.
! 
! SACAMOS uses the EISPACK library (in /SRC/EISPACK). EISPACK is subject to 
! the GNU Lesser General Public License. A copy of the GNU Lesser General Public 
! License version can be found in the file GNU_LGPL in the root of EISPACK 
! (/SRC/EISPACK ) or at <http://www.gnu.org/licenses/>.
! 
! The University of Nottingham can be contacted at: ggiemr@nottingham.ac.uk
!
fe64b32b   Chris Smartt   Update file heade...
28
!
886c558b   Steve Greedy   SACAMOS Public Re...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
! File Contents:
! SUBROUTINE write_spice_dc_resistances
!
! NAME
!     write_spice_dc_resistances
!
! AUTHORS
!     Chris Smartt
!
! DESCRIPTION
!     write the d.c. resistances on each of the terminal conductors
!
!     INPUTS REQUIRED
!     1. The conductor based node numbers at the terminations of the bundle
!     2. A 1D array of d.c. resistance values
!     3. The first free node available
!     4. The reference node number
!    note that the last conductor is connected to the reference node
!     5. The bundle length
!
!     OUTPUTS
!     1. The components required to implement the model are written to
!        the subcircuit file
!     2. The nodes on the d.c. resistances are returned to the calling process for connection to the domain decomposition model
!     
! COMMENTS
!      note that the d.c. resistance of a conductor is split equally between the two ends
!
! HISTORY
!
!     STAGE 4 developments started 22/4/2016 CJS
!
SUBROUTINE write_spice_dc_resistances( vref_node,next_free_node,Rdc,n_conductors,end,external_nodes,rdc_nodes,length)
  
USE type_specifications
USE general_module
USE spice_cable_bundle_module

IMPLICIT NONE

! variables passed to the subroutine

  integer,intent(IN)     :: vref_node                       ! sub-circuit reference node number
  integer,intent(INOUT)  :: next_free_node                  ! next free spice subcircuit node number 
  integer ,intent(IN)    :: n_conductors                    ! total number of conductors
  real(dp),intent(IN)    :: Rdc(1:n_conductors)             ! d.c. resistance per unit length of conductor
  integer,intent(IN)     :: end                             ! end number of transmission line (1 or 2)
  integer,intent(IN)     :: external_nodes(1:n_conductors)  ! external node numbers for sub-circuit (these are known on input)
  integer,intent(OUT)    :: rdc_nodes(1:n_conductors)       ! node numbers on the d.c. resistance   (these generated here and returned)
  real(dp),intent(IN)    :: length                          ! length of conductor (m)

! local variables

  character(LEN=spice_name_length) :: name_head          ! head of the name for the d.c. resistance circuit elements
  character(LEN=spice_name_length) :: Rdc_name           ! full name for the d.c. resistance circuit elements, includes conductor and end number

  integer :: conductor   ! conductor loop variable

! START
   
  name_head='Rdc'

!loop over conductors  
  do conductor=1,n_conductors

! create the component name with the conductor and end number  
    CALL build_name_with_conductor_and_end(name_head,conductor,end,Rdc_name)
    
    if (conductor.NE.n_conductors) then
! create a new node
      rdc_nodes(conductor)=next_free_node
      next_free_node=next_free_node+1
    else
! connect the last conductor to the reference node for the transmission line model
      rdc_nodes(conductor)=vref_node
    end if

! Note that half the d.c. resistance of the bundle goes at each end    
    write(spice_model_file_unit,'(A30,2I6,ES16.6)')Rdc_name,external_nodes(conductor),rdc_nodes(conductor),Rdc(conductor)*length/2d0
     
  end do
    
  RETURN

END SUBROUTINE write_spice_dc_resistances