[TRNSYS-users] Changing a parameter to input in components

Jaime Gonzalez Rodriguez gonzalezro.jaime at gmail.com
Mon Jul 12 17:03:47 PDT 2010


well, you just have to find the code of the type you wanna change, for
instance type212.for or whatever...then, as David said you have to change
the parameter to input, I'll do it in the code that you pasted before so
that you can see an example, anyway my trnsys  function library seems to be
kind of different to yours, but this should work.

Other topic is how to recompile it, I guess you should create a project and
set the right options to the compiler, you've got two options.

1. Copy the options of the project that trnsys created for you with the type
you have built before, those options should be the same

2. Create a new component, create the .tmf with the number of parameters,
inputs and outputs that you want, and then copy and paste the code, be
carefull with this, don't paste the part where you define the number of
parameters or the part with the type number, just the core of the code, I
mean, the part where you carry out the calculations.

I preffer the option 2 because I am too lazy to fight with windows
compilers, but the first option might be better.


When I started programming types I didn't remember much about fortran cuz I
was programming C and other languages (mostly matlab which is the easiest)
for a long time and I had forgotten almost everything from university, it
was a nice exercise to read a code of a type and try to understand
everything. If I were you I'd try so.


Regards and good luck with fortran =)



-------------------------------------------------------------------------------------------------------------------------------------------------------

!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 SetNumberofParameters(0)           !The number
of parameters that the the model wants

                        !Call SetNumberofInputs(1)                   !The
number of inputs that the the model wants

                        Call SetNumberofInputs(2)                   !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) I comment this line cuz u won't need it
anymore





      inp1 = GetInputValue(1)

      inp2 = GetInputValue(2)





   !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) Since you don't have parameters you won't
need this neither





      EndIf

!-----------------------------------------------------------------------------------------------------------------------



!Read the Inputs

      inp1 = GetInputValue(1)

      inp2 = GetInputValue(2)





            !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



!     finally where you calculated the value of the formula you should
change PAR1 for IN2
      OUT1=IN1+PAR1
!    DON'T FORGET TO ADD THE DECLARATION OF THE VARIABLE IN2 AND DELETE THE
DECLARATION OF PAR1
!    Note: As far as you declare the variables you can call them with any
name you want, it does not have to be
Double IN1
Double IN2
it could be
Double SPAINWORLDCHAMPIONS
Double whatever





On 12 July 2010 21:04, Mehdi Shahrestani <mahdishahrestani at yahoo.com> wrote:

>  Dear David
>
>
>
> Thanks for your reply
>
> To be honest I try to change the script but I don’t know how I can
> recompile the edited file.
>
> I was wondering if you could give me some hints about recompiling an edited
> fortran file.
>
>
>
> Regards
>
> Mehdi Shahrestani
>
>
>
>
>
>
>  ------------------------------
>
> *From:* David Bradley [mailto:bradley at tess-inc.com]
> *Sent:* 12 July 2010 18:16
> *To:* mehdi
> *Cc:* trnsys-users at cae.wisc.edu
> *Subject:* Re: [TRNSYS-users] Changing a parameter to input in components
>
>
>
> Mehdi,
>   In addition to changing the proforma, you also need to modify and
> recompile the Fortran code of the Type and change the number of parameters
> and inputs that it expecting to be passed.
> Best,
>  David
>
>
> On 7/11/2010 17:37, mehdi wrote:
>
> Hello everybody
>
>
>
> I have a question about changing a “Parameter” into “Input” in components.
>
>
>
> For example in a pipe component, I have changed one of parameters to input
> (in Performa) but after run there were two errors mentioned that
>
> There is one missed parameter and one more than normal input.
>
>
>
> I think there should be a way to solve such a problem.
>
> I was wondering if anybody could give some advice.
>
>
>
> Regards
>
> Mehdi Shahrestani
>
>
>
>
>
>
>
> _______________________________________________
>
> TRNSYS-users mailing list
>
> TRNSYS-users at cae.wisc.edu
>
> https://www-old.cae.wisc.edu/mailman/listinfo/trnsys-users
>
>
>
>
>
>  --
>
> ***************************
>
> David BRADLEY
>
> Principal
>
> Thermal Energy Systems Specialists, LLC
>
> 22 North Carroll Street - suite 370
>
> Madison, WI  53703 USA
>
>
>
> P:+1.608.274.2577
>
> F:+1.608.278.1475
>
> bradley at tess-inc.com
>
>
>
> http://www.tess-inc.com
>
> http://www.trnsys.com
>
>
> _______________________________________________
> 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/20100713/fd651318/attachment-0001.htm>


More information about the TRNSYS-users mailing list