[TRNSYS-users] problem in creating a simple new component
Jaime Gonzalez Rodriguez
gonzalezro.jaime at gmail.com
Mon Jul 12 04:55:58 PDT 2010
you have writen it there, but it is commented. You have to uncomment the
line where it says
!Sample Code: OUT1=IN1+PAR1
so that it would be:
OUT1=IN1+PAR1
You also have to write the same line in the part where it says (!Do All of
the First Timestep Manipulations Here - There Are No Iterations at the
Intial Time) after getting the input value and before writting the output
value.
Which trnsys version are you using??? code is kind of different to the one
created by mine when I export new proformas
Regards
On 12 July 2010 13:32, mehdi <mahdishahrestani at yahoo.com> wrote:
> *Hello everybody *
>
>
>
> I have problem in creating the new component utilising simulation studio
> skeleton to create new components.
>
>
>
> Description of new component that I am going to create:
>
> *Input, output and parameters:*
>
> * *
>
> *Input:* inp
>
> *Output:* opt
>
> *Parameter:* par
>
> *Equation: *
>
> *Opt = inp + par *
>
> * *
>
> After exporting the performa to fortran the codes comes up in VBF6.6B but
> unfortunately I don’t know where I should add my simple equation in the
> script.
>
> I Transys manual 1-68 has been mentioned that we have to add our equations
> instead of highlight question marks in the fortran script. But in the
> fortran file there is no question mark.
>
>
>
> The tmf file along with fortran file have been attached and also the
> fortran script has been mentioned below.
>
>
>
> I was wondering if you could help to run this simple component.
>
>
>
> Regards
>
> Mehdi Shahrestani
>
>
>
>
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
>
> Subroutine Type211
>
>
>
> ! Object: Noname
>
> ! Simulation Studio Model: type211
>
> !
>
>
>
> ! Author:
>
> ! Editor:
>
> ! Date: July 12, 2010
>
> ! last modified: July 12, 2010
>
> !
>
> !
>
> ! ***
>
> ! *** Model Parameters
>
> ! ***
>
> ! par - [-Inf;+Inf]
>
>
>
> ! ***
>
> ! *** Model Inputs
>
> ! ***
>
> ! inp - [-Inf;+Inf]
>
>
>
> ! ***
>
> ! *** Model Outputs
>
> ! ***
>
> ! opt - [-Inf;+Inf]
>
>
>
> ! ***
>
> ! *** Model Derivatives
>
> ! ***
>
>
>
> ! (Comments and routine interface generated by TRNSYS Studio)
>
> !************************************************************************
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> ! This TRNSYS component skeleton was generated from the TRNSYS studio based
> on the user-supplied parameters, inputs,
>
> ! outputs, and derivatives. The user should check the component
> formulation carefully and add the content to transform
>
> ! the parameters, inputs and derivatives into outputs. Remember, outputs
> should be the average value over the timestep
>
> ! and not the value at the end of the timestep; although in many models
> these are exactly the same values. Refer to
>
> ! existing types for examples of using advanced features inside the model
> (Formats, Labels etc.)
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
>
> Use TrnsysConstants
>
> Use TrnsysFunctions
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
> !DEC$Attributes DLLexport :: Type211
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !Trnsys Declarations
>
> Implicit None
>
>
>
> Double Precision Timestep,Time
>
> Integer CurrentUnit,CurrentType
>
>
>
>
>
> ! PARAMETERS
>
> DOUBLE PRECISION par
>
>
>
> ! INPUTS
>
> DOUBLE PRECISION inp
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !Get the Global Trnsys Simulation Variables
>
> Time=getSimulationTime()
>
> Timestep=getSimulationTimeStep()
>
> CurrentUnit = getCurrentUnit()
>
> CurrentType = getCurrentType()
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !Set the Version Number for This Type
>
> If(getIsVersionSigningTime()) Then
>
> Call SetTypeVersion(17)
>
> Return
>
> EndIf
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !Do Any Last Call Manipulations Here
>
> If(getIsLastCallofSimulation()) Then
>
> Return
>
> EndIf
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !Perform Any "After Convergence" Manipulations That May Be Required at the
> End of Each Timestep
>
> If(getIsConvergenceReached()) Then
>
> Return
>
> EndIf
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !Do All of the "Very First Call of the Simulation Manipulations" Here
>
> If(getIsFirstCallofSimulation()) Then
>
>
>
> !Tell the TRNSYS Engine How This Type Works
>
> Call SetNumberofParameters(1) !The number
> of parameters that the the model wants
>
> Call SetNumberofInputs(1) !The
> number of inputs that the the model wants
>
> Call SetNumberofDerivatives(0) !The number
> of derivatives that the the model wants
>
> Call SetNumberofOutputs(1) !The
> number of outputs that the the model produces
>
> Call SetIterationMode(1)
> !An indicator for the iteration mode (default=1). Refer
> to section 8.4.3.5 of the documentation for more details.
>
> Call
> SetNumberStoredVariables(0,0) !The number of static
> variables that the model wants stored in the global storage array and the
> number of dynamic variables that the model wants stored in the global
> storage array
>
> Call SetNumberofDiscreteControls(0)
> !The number of discrete control functions set by this model (a value greater
> than zero requires the user to use Solver 1: Powell's method)
>
>
>
> Return
>
>
>
> EndIf
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !Do All of the First Timestep Manipulations Here - There Are No Iterations
> at the Intial Time
>
> If (getIsFirstTimestep()) Then
>
> par = getParameterValue(1)
>
>
>
>
>
> inp = GetInputValue(1)
>
>
>
>
>
> !Check the Parameters for Problems (#,ErrorType,Text)
>
> !Sample Code: If( PAR1 <= 0.) Call FoundBadParameter(1,'Fatal','The
> first parameter provided to this model is not acceptable.')
>
>
>
> !Set the Initial Values of the Outputs (#,Value)
>
> Call SetOutputValue(1, 0) ! opt
>
>
>
>
>
> !If Needed, Set the Initial Values of the Static Storage Variables
> (#,Value)
>
> !Sample Code: SetStaticArrayValue(1,0.d0)
>
>
>
> !If Needed, Set the Initial Values of the Dynamic Storage Variables
> (#,Value)
>
> !Sample Code: Call SetDynamicArrayValueThisIteration(1,20.d0)
>
>
>
> !If Needed, Set the Initial Values of the Discrete Controllers (#,Value)
>
> !Sample Code for Controller 1 Set to Off: Call
> SetDesiredDiscreteControlState(1,0)
>
>
>
> Return
>
>
>
> EndIf
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !ReRead the Parameters if Another Unit of This Type Has Been Called Last
>
> If(getIsReReadParameters()) Then
>
> !Read in the Values of the Parameters from the
> Input File
>
> par = getParameterValue(1)
>
>
>
>
>
> EndIf
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
> !Read the Inputs
>
> inp = GetInputValue(1)
>
>
>
>
>
> !Check the Inputs for Problems (#,ErrorType,Text)
>
> !Sample Code: If( IN1 <= 0.) Call FoundBadInput(1,'Fatal','The
> first input provided to this model is not acceptable.')
>
>
>
> If(ErrorFound()) Return
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> ! *** PERFORM ALL THE CALCULATION HERE FOR THIS MODEL. ***
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !If Needed, Get the Previous Control States if Discrete
> Controllers are Being Used (#)
>
> !Sample Code: CONTROL_LAST=getPreviousControlState(1)
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !If Needed, Get the Values from the Global Storage Array for
> the Static Variables (#)
>
> !Sample Code: STATIC1=getStaticArrayValue(1)
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !If Needed, Get the Initial Values of the Dynamic Variables
> from the Global Storage Array (#)
>
> !Sample Code: T_INITIAL_1=getDynamicArrayValueLastTimestep(1)
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !Perform All of the Calculations Here to Set the Outputs from
> the Model Based on the Inputs
>
>
>
> !Sample Code: OUT1=IN1+PAR1
>
>
>
> !If the model requires the solution of numerical derivatives,
> set these derivatives and get the current solution
>
> !Sample Code: T1=getNumericalSolution(1)
>
> !Sample Code: T2=getNumericalSolution(2)
>
> !Sample Code: DTDT1=3.*T2+7.*T1-15.
>
> !Sample Code: DTDT2=-2.*T1+11.*T2+21.
>
> !Sample Code: Call SetNumericalDerivative(1,DTDT1)
>
> !Sample Code: Call SetNumericalDerivative(2,DTDT2)
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !Set the Outputs from this Model (#,Value)
>
> Call SetOutputValue(1, 0) ! opt
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !If Needed, Store the Desired Disceret Control Signal Values for this
> Iteration (#,State)
>
> !Sample Code: Call SetDesiredDiscreteControlState(1,1)
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
> !If Needed, Store the Final value of the Dynamic Variables in the Global
> Storage Array (#,Value)
>
> !Sample Code: Call SetValueThisIteration(1,T_FINAL_1)
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
> Return
>
> End
>
>
> !-----------------------------------------------------------------------------------------------------------------------
>
>
>
>
>
>
>
> _______________________________________________
> TRNSYS-users mailing list
> TRNSYS-users at cae.wisc.edu
> https://www-old.cae.wisc.edu/mailman/listinfo/trnsys-users
>
>
--
Jaime. González Rodríguez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/attachments/20100712/3b6ccc88/attachment.htm>
More information about the TRNSYS-users
mailing list