General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

[Thermal] APDL scripting to control heat input over time

    • remi.gerard-marzan
      Subscriber

      Hello everyone,

      I am using the very convenient Thermostat PID extension from ACT in an ongoing project. However, I would like to have it work only some of the time (it's for thermal control of a satellite and I don't want the control to be active when the satellite is in eclipse). What the extension does is to input some power in a given surface or element when its temperature drops below a certain point, but it can't be parameterized against time.

      Would anyone have an idea to "force" the surfaces on which the extension is applied to become "adiabatic" for a certain time period, so as to effectively block off the thermostat during these times?

      Best regards,

      Rémi

    • mjmiddle
      Ansys Employee
      When you install the binary extension, it will unpack the scripted version to %APPDATA%\Ansys\v{version}\ACT\extensions. You are free to modify the python file to get the behavior you want.
       
      This extension was written by PADT. So, alternatively, you could contact PADT about the extension: info@padtinc.com. Or if you look inside the folders of the extension, the documentation inside says to contact matt.sutton@padtinc.com.
       
      For Mechanical thermal analysis, when no boundary condition is assigned on a face, that enforces a flux parallel condition, which is adiabatic. So you really just need to deactivate the load for certain load steps.
    • remi.gerard-marzan
      Subscriber

      Thank you for your answer. I will contact PADT. As it currently works, the extension cannot be selectively deactivated at certain time steps, but maybe that can be programmed in the Python file. Any ideas how such a thing could be achieved?

      Best regards,

      Rémi

    • mjmiddle
      Ansys Employee

      Editing python files to allow a row of the table to be marked as deactivated may be too much work. The python file in the extension does not manage the table. You would need to copy some files from {ansys_install}\Addins\ACT\libraries\Mechanical\Worksheet to your extension and modify them.

      You are better off trying an override method. You could almost do it by inserting a "Perfected Insulated" condition, but it doesn't have a table to deactivate for some load steps. And a "heat flow" won't accept a zero entry only

      But you can write the APDL file with a heat flow with a zero entry, a nonzero, and a deactivated step to see what it writes, then use these commands in your own command snippet.

      In the details you can set the load step for which a command snippet applies:

    • mjmiddle
      Ansys Employee

       

      The above heat flow with 0,5,0,inactive steps produces:
       
      et,6,152
      eblock,10,,,32
      (15i9)
      {element definitions}
      -1
      esel,s,type,,6
      keyop,6,8,1      ! include heat flux
       
      *DIM,_loadvari75,TABLE,3,1,1,TIME, , , 0
      ! Time values
      *TAXIS,_loadvari75(1),1,0.,1.,2.
      ! Load values
      _loadvari75(1,1,1) = 0.
      _loadvari75(2,1,1) = 0.555555555555597
      _loadvari75(3,1,1) = 0.
       
      It then applies the load before all load step solves:
       
      esel,s,type,,6
      nsle
      sf,all,hflux,%_loadvari75%
       
      In LS 3 it deactivates with:
       
      esel,s,type,,6
      nsle
      sfdel,all,all
       
      To get the selection in your code, you’ll want to make a named selection of the face(s), then use CMSEL to selection the nodal selection of those faces. Since you’ll already have a nodal selection, there’s no need to use NSLE.
      Get the largest element type number with a *GET command, add one, then use that in your ET command. You can use ESURF to generate the surface elements. Use TYPE command to set the type number before the ESURF. When you deactivate a middle load setp, it uses SFDEL to delete the load, then it reapplies the table the same way as before in the next load step before the next solve:
       
      esel,s,type,,6
      nsle
      sf,all,hflux,%_loadvari75%
       
      On the other hand, this is a separate load than what the extension applies, so it may try to apply both in some way (if loads are additive: FCUM,ADD; but you can turn that off in your code). You should write out the APDL file after applying the load with the ACT extnesion to see how it does this. You may just need to delete the load for those steps you want to deactivate then reapply using the same table created by the ACT extension.
      You obviously need to get some APDL command experience. You can see all the commands listed alphabetically here:
      https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v252/en/ans_cmd/Hlp_C_CmdTOC.html

       

    • mjmiddle
      Ansys Employee

       

       

       

    • remi.gerard-marzan
      Subscriber

      Thank you for your detailed answer and the time you have taken to write it. As it happens, I have separately decided to follow the same idea: the documentation included in the presentation of the thermostat ACT contains a simplified APDL script working as a basic thermostat (this is to highlight how the ACT thermostat is better. Hat's off to the PADT guys for such a thorough documentation, by the way).

      I have therefore removed the ACT from my model entirely. Instead of that, I have placed the APDL script, which I have lightly modified to adapt it to my own purposes. It looks like this:

      LA = 3.626e-3                    !Load area (m^2)
      Power = 1                      !Applied power (W)
      endtime = 6000                   !endtime (s)
      step_length = 400                 !for how long do we want the heating to apply (s)
      step_start_time = 0             !time at which the heating should start (s)    
      target1 = -6                      !target temperature (100)
      target2 = -4
      loadstp = 50                      !number of load steps to use
      totsbstp = 100                !total number of substeps to use
      numsbstp = nint(totsbstp/loadstp) !
       
      *get,nmax_,node,,num,max
      *dim,nsol_,,nmax_,3
      *vfill,nsol_(1,1),ramp,1,1
      cmsel,s,L1_probe_vertex_mesh
      *vget,nsol_(1,2),node,1,nsel
      tnode=ndnext(0)
      allsel,
       
      *do,i,1,loadstp
          time,endtime*i/loadstp
          *vmask,nsol_(1,2)
          *vget,nsol_(1,3),node,1,temp  !get temperature
          *vmask,nsol_(1,2)
          *vscfun,ttemp,mean,nsol_(1,3) !get mean value
          *if,endtime*i/loadstp,lt,3428,then !if current time within targetted step
              *if,endtime*i/loadstp,gt,668,then !if current time within targetted step
                  *if,ttemp,gt,target2,then      !if temperature > target2 then stop
                      sfdele,L1_heating_surface,hflux
                  *else
                      *if,ttemp,lt,target1,then      !if temperature < target1 then apply load
                          sf,L1_heating_surface,hflux,Power/LA  
                      *endif
                  *endif
              *else
                  sfdele,L1_heating_surface,hflux
              *endif
          *else
              sfdele,L1_heating_surface,hflux
          *endif
          nsubst,numsbstp,totsbstp,numsbstp
          solve
      *ENDDO

      I have tested it and it works alright...indeed, it takes the temperature located at the mesh node contained in the "L1_probe_vertex_mesh" named selection. It then computes a bizarre self-referenced timer (this "endtime*i/loadstp"). Then, if this timer is between 668s and 3428s and if this temperature is higher than -4°C, the heater is shut down, if it is lower than -6°C, the heater is applied.

      This script uses a lot of elements you have brought forth in your previous answer.

      I would have a few questions about deactivating the APDL script outside of a specific step. In a previous iteration of that script, I did try to do this: I had defined Step 1 from 0 to 668s, then Step 2 from 668s to 3428s, then Step 3 from 3428s to 6000s. I then deactivated the APDL outside of Step 2. Yet, I noticed that the heat flux was being applied at all times anyway. It might have to do with the way this "do" loop works, with that "solve" at the end of it. Would you have a clue as to why this was happening, and how I might contain my script activation to a specific step? That would allow me to remove 2 "if" loops.

      Best regards,

      Rémi

    • mjmiddle
      Ansys Employee

      If your commands issue a solve, you should turn it off in the details so mechanical doesn't issue it's own solve:

      But, yes, this screws around with the way Mechanical wants to solve for the load steps, so you have to know what you are doing. And the commands are looping through its own load steps, so that's going to screw around with the load step numbers Mechanical understands. Usually when you take over the solves in a command snippet you handle all the solves there, and don't have Mechanical do any solves. Set the "Step selection mode" to all, and "issue solve command" to no, and Mechanical won't do any solves. Your script then handles looping over all load steps and the solve for each one. Your heat flux will only be applied within your commands, not with a native Mechanical "heat flux" in the Outline.

Viewing 7 reply threads
  • You must be logged in to reply to this topic.