################################################################################
# SABER MODEL : ED:1 REV:1
# AUTHOR : OCSIMIZE DATE:12/08/04
#
# FICHIER transformer_spl.sin : ind.a
# ETAT : valid
################################################################################
#==============================================================================#
element template transformer_spl vp vm p m = k, efficiency
#==============================================================================#
################################################################################
# Copyright 2004 to infinity and beyond..., Ocsimize.
# This template may not be reproduced or modified
# without permission from Ocsimize. Ocsimize does not assume
# liability for the use of this template or the results
# obtained from using it as long as it is not validated by the final user.
# Usage of this template is allowed for customers of Ocsimize's customers
################################################################################
################################################################################
# MODIFICATION
#
# 12/08/04: creation
#
################################################################################
#
# pins
#
################################################################################
# Name Type Signification
#
# vp electrical positive input
# vm electrical negative input
# p electrical positive output
# m electrical negative output
#
################################################################################
#
# Parameters definition
#
################################################################################
# Name Default value Signification
#
# k 1 ratio of voltage and current
# efficiency 1 transformer efficiency
#
################################################################################
#
# Postprocess information
#
################################################################################
# Name Unit Signification
#
# powerin W input power
# powerout W output power
#
################################################################################
#
# usage
#
################################################################################
#
# This template represents a general behavioural transformer
# with ratio and efficiency as parameters
#
#
# Use :
#
# -----------
# (vp) O---| |-----O (p)
# | |
# (vm) O---| |-----O (m)
# | |
# -----------
#
# we have v(p) - v(m) = k* (v(vp) - v(vm)) then the input current
# is imposed by the power equation for efficiency = 1 then
# curin = k*curout
#
################################################################################
# Notes :
################################################################################
#
#
################################################################################
electrical vp,vm,p,m
number k = 1, efficiency = 1
{
val i curin
var i curout
val v vin, vinter, vout
val p powerin, powerout
number efficiency_cal
#
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
parameters {
if (efficiency <= 0 | efficiency > 1) {
message("\n")
message("TMPL_W_RANGE % : \n \n", instance())
warning("\t % must be > % and <= %. Changed from % to %. \n \n", \
"efficiency","0","1",efficiency,"1")
# saber_message("TMPL_W_RANGE",instance(),"efficiency","0","1",efficiency,"1")
efficiency_cal = 1
}
else {
efficiency_cal = efficiency
}
}
#
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
values {
vin = v(vp) - v(vm)
vout = v(p) - v(m)
if (abs(vin) > 1u) {
curin = -vout*curout/vin/efficiency_cal
}
else {
curin = 0
}
powerin = vin*curin
powerout = vout*curout
}
#
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
equations {
i(vp) += curin
i(vm) -= curin
i(p) += curout
i(m) -= curout
curout : vout = k*vin
}
}