Free text input, Heat Source: How to express a complex function whose amplitude varies with a square wave.

Numerical methods and mathematical models of Elmer
Post Reply
ScientistRenzo
Posts: 57
Joined: 14 Mar 2021, 21:01
Antispam: Yes

Free text input, Heat Source: How to express a complex function whose amplitude varies with a square wave.

Post by ScientistRenzo »

Title: Free text input, Heat Source: How to express a complex function whose amplitude varies with a square wave.

My heat source free text input for example is:
Heat Source = variable coordinate 1, coordinate 2, coordinate 3, time
MATC "(100) * (tx(2)) * ((1-tx(3))/10000) * (123*tx(1)) * (1.5 + wv1(t))"

wv1(t) is a square wave function with respect to time. How can I add that in to the above equation? ElmerGUI manual says I can make a peicewise like this: https://imgur.com/a/47ZWTk3. Still I don't know.

For referencing, my square wave will have these properties:
T = 10.43254 sec
t_high = .044859922 sec
outputting
[1] during 0 to .044859922 sec
[0] during .044859922 to 10.43254 sec
[1] during 10.43254 to 10.47739992 sec
[0] during 10.47739992 to 20.86508 sec

If you know how I can parameterize this
0 to t_high
t_high to T
T to T+t_high
T+t_high to T*2

Thank you!
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Free text input, Heat Source: How to express a complex function whose amplitude varies with a square wave.

Post by kevinarden »

When the function gets that complex you should use a user defined function which allows you to program your own subroutine. However MATC does allow if statements.

https://www.nic.funet.fi/pub/sci/physic ... torial.pdf

Chapter 1
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Free text input, Heat Source: How to express a complex function whose amplitude varies with a square wave.

Post by raback »

Hi

You can use a table if you have just a few irregular steps as in your case, for example

Code: Select all

Heat Source = Variable "time"
  Real
    0.0 1
    1.0 1
    1.001 0 
    2.0 0
    2.001 1
    4.0 1
    4.001 0
    7.0 0
    ...
  End 
  
If you would have regular square waves then use of "sign" function would make sense.

-Peter
ScientistRenzo
Posts: 57
Joined: 14 Mar 2021, 21:01
Antispam: Yes

Re: Free text input, Heat Source: How to express a complex function whose amplitude varies with a square wave.

Post by ScientistRenzo »

Ah thank you so much Peter.

And I may use those procedures some day. Thank you kevinarden.
ScientistRenzo
Posts: 57
Joined: 14 Mar 2021, 21:01
Antispam: Yes

Re: Free text input, Heat Source: How to express a complex function whose amplitude varies with a square wave.

Post by ScientistRenzo »

Peter!
Will including "variable coordinate 1" and referring to it by "tx(1)" still work within the table?

Thank you...
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Free text input, Heat Source: How to express a complex function whose amplitude varies with a square wave.

Post by raback »

No, just one variable for table. If you need a distribution at the same time use rather a small fortran function. -Peter
Post Reply