subroutine strand_init_part1(me, krn, cfg, h5, sim)
type(strand_t), intent(out) :: me
type(krn_t), intent(inout) :: krn
class(input_t), pointer, intent(in) :: cfg
class(hdf5_t), intent(inout) :: h5
type(simulation_t), intent(inout) :: sim
real(dp) :: T_init, num, den
integer :: i, ii, nb_non_zeros_exp, nb_non_zeros_imp, nb_FS_ports
if(cfg%has_key('nodes')) then ! means uniform mesh
me%SC_Prop%NbCells = cfg%int('nodes')
me%SC_Prop%Length = cfg%dbl('length')
allocate(me%SC_Prop%dxLoc(me%SC_Prop%NbCells))
me%SC_Prop%dxLoc(:)=me%SC_Prop%Length/me%SC_Prop%NbCells
else ! variable mesh
me%SC_Prop%NbCells=size(cfg%dbl1d('length'))
allocate(me%SC_Prop%dxLoc(me%SC_Prop%NbCells))
me%SC_Prop%dxLoc(:)=cfg%dbl1d('length')
me%SC_Prop%Length = sum(me%SC_Prop%dxLoc(:))
endif
! For HDF5
me%hdf%name = cfg%str('id')
me%hdf%node_x = [(sum(me%SC_Prop%dxLoc(1:i-1)) + me%SC_Prop%dxLoc(i)/2, i = 1, me%SC_Prop%NbCells)]
call h5%add_to_table(me%hdf,'strand')
me%NbConst=2
call all_strand_allocation(me)
T_init=cfg%dbl('initial/t')
do ii=1,me%SC_Prop%NbCells
me%StVar%SCtemp(ii)=T_init
enddo
call material_init(me%mat_stab,cfg%dict('stabilizer'))
call material_init(me%mat_supc,cfg%dict('superconductor'))
me%ct(1)%area = cfg%dbl('stabilizer/area')
me%ct(1)%type = 'stabilizer'
me%ct(2)%area = cfg%dbl('superconductor/area')
me%ct(2)%type = 'superconductor'
num=me%ct(STAB)%area*me%mat_stab%density+me%ct(SUPC)%area*me%mat_supc%density
den=me%ct(STAB)%area+me%ct(SUPC)%area
me%ro_M=num/den
me%SC_Prop%inner_rad=cfg%dbl('CICC_inner_radius')
me%SC_Prop%outer_rad=cfg%dbl('CICC_outer_radius')
me%SC_Prop%FSlink = cfg%bin('channel_link')
! default values for 1d_signal
call me%scen%Q_ext_load%init(sim,cfg,'flux',me%hdf%node_x)
call me%scen%Bfield_load%init(sim,cfg,'field',me%hdf%node_x)
call me%scen%dBfield_load%init(sim,cfg,'field_gradient',me%hdf%node_x)
call me%scen%ElCur_load%init(sim,cfg,'current')
nb_non_zeros_exp=me%SC_Prop%NbCells
nb_non_zeros_imp=2
do i=2,me%SC_Prop%NbCells-1
nb_non_zeros_imp=nb_non_zeros_imp+3
enddo
nb_non_zeros_imp=nb_non_zeros_imp+2
if(me%SC_Prop%FSlink) then
nb_FS_ports=me%SC_Prop%NbCells
else
nb_FS_ports=0
endif
call krn%add(cfg%str('id'),me%SC_Prop%NbCells,nb_non_zeros_exp,nb_non_zeros_imp,0,nb_FS_ports,0,2,0)
end subroutine strand_init_part1