swage question Log Out | Topics | Search
Moderators | Register | Edit Profile

FlexPDE User's Forum » User Postings » swage question « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Kevin Ellwood (ikevin)
Member
Username: ikevin

Post Number: 21
Registered: 06-2003
Posted on Wednesday, July 28, 2004 - 11:35 am:   

Hi

Can the arguments to the swage function be scalar variables that were read in using the transfermesh function? Something like this:

transfer('file1.dat',temp1)
transfer('file2.dat',temp2)
.....
temp = swage( (t-10.0), temp1, temp2, 0.5)


Also, could temp2 be replaced with a constant? Something like:

temp = swage( (t-10.0), temp1, 100.0, 0.5)

Thanks
kev
Top of pagePrevious messageNext messageBottom of page Link to this message

Robert G. Nelson (rgnelson)
Moderator
Username: rgnelson

Post Number: 199
Registered: 06-2003
Posted on Wednesday, July 28, 2004 - 02:34 pm:   

Like any other function, SWAGE evaluates its arguments dynamically as needed, so anything you put there will be evaluated at the time of use. So either of your examples is acceptable.

As far as reading scalar variables in a TRANSFER, it wont work quite like you expect. TRANSFER does not have provision for identifying scalar variables, so what you will get is a full mesh of data, all with the same value. It should work OK, but it might cost more than you thought it would.

The best way to export scalars is to write them in a summary and read them with #include:
SUMMARY ("") EXPORT FILE="scalardata"
REPORT(a+b) AS "Thing"
will write file "scalardata" containing bracketed comments and the line
Thing=<numeric>
You can #include this file and it will look like a standard parameter definition.
Top of pagePrevious messageNext messageBottom of page Link to this message

Kevin Ellwood (ikevin)
Member
Username: ikevin

Post Number: 22
Registered: 06-2003
Posted on Wednesday, July 28, 2004 - 03:13 pm:   

Thanks

I mispoke in my first post. temp1 and temp2 are functions of position, not a constant. This is why I used the TRANSFER function.

Thanks again for your answer,
Kevin
Top of pagePrevious messageNext messageBottom of page Link to this message

Kevin Ellwood (ikevin)
Member
Username: ikevin

Post Number: 23
Registered: 06-2003
Posted on Wednesday, July 28, 2004 - 03:57 pm:   

Hi Robert

One more slightly related question. Below is my block of code that represents the temperature profile that I am trying to achieve. I have tested it in small codes and it seems fine. My problem is in the big runs, some features of the cycle are missed due to miss match in timesteps -- they get very large.

I know how to force flexpde to evaluate at a particular timestep using the plot function with "for t= ...". How do this for periodic set of plots?

Thanks
Kevin
transfer('tire_temp_trans.dat',temp_init)
temp1 = SAVE(temp_init)
trest = 273.0+20.0
tint = 5*60
tc= mod(t,86400)
ts1 = 25100.0
ts2 = ts1 + 3700.0
ts3 = ts2 + 28800.0
ts4 = ts3 + 3700.0

t1 = (0.0+ts1)/2.0
t2 = (ts1+ts2)/2.0
t3 = (ts2+ts3)/2.0
t4 = (ts3+ts4)/2.0
t5 = (ts4+86400.0)/2.0
T0 = if (tc<t1) then trest
else if (tc<t2) then swage(tc-ts1,trest,temp1,tint)
else if (tc<t3) then swage(tc-ts2,temp1,trest,tint)
else if (tc<t4) then swage(tc-ts3,trest,temp1,tint)
else if (tc<t5) then swage(tc-ts4,temp1,trest,tint)
else trest
Top of pagePrevious messageNext messageBottom of page Link to this message

Robert G. Nelson (rgnelson)
Moderator
Username: rgnelson

Post Number: 200
Registered: 06-2003
Posted on Wednesday, July 28, 2004 - 04:51 pm:   

This is getting a little clumsy, but it should work:
for t=ts1 by 86400 to endtime contour(something)
for t=ts2 by 86400 to endtime contour(something)
for t=ts3 by 86400 to endtime contour(something)
for t=ts4 by 86400 to endtime contour(something)

You can't leave out the plots, or the break times will be ignored.
Top of pagePrevious messageNext messageBottom of page Link to this message

Laurent Simon (lsimon)
New member
Username: lsimon

Post Number: 1
Registered: 06-2005
Posted on Wednesday, June 29, 2005 - 07:42 pm:   

Greetings:
Your explanation (and Kevin's) on the use of SWAGE for the temperature problem (post number: 23) helped me immensely. I was able to generate a temperature profile that has some discontinuity. My problem is that the temperature is then used in a differential equation. The program spends a fair amount of time at the discontinuites and uses a very small Dt even after the discontinuities. Is there any remedy?
Thank you
Laurent

This is a copy of the problem:
{ problem.PDE }


title
"problem"

select
nodelimit=100
coordinates
cartesian1

variables
Ca(threshold=0.0)
cp(threshold=0.00001)
qtot(threshold=0.000001)

definitions
dif0 = 0.00002
Ed = 20689.84707
T0 = 305.15
R = 1.987
Cs0 = 51600
Es =5380
L = 0.02



tint = 0.01;
tc= t
ts1 = 10
ts2 = 20
ts3 =30
ts4 = 40

t1 = (0.0+ts1)/2.0
t2 = (ts1+ts2)/2.0
t3 = (ts2+ts3)/2.0
t4 = (ts3+ts4)/2.0
t5 = (ts4+48)/2.0

Ts = if (tc<t1) then 273.15+20
else if (tc<t2) then swage(tc-ts1, 273.15+20, 273.15 + 40,tint)
else if (tc<t3) then swage(tc-ts2, 273.15 + 40, 273.15 + 30, tint)
else if (tc<t4) then swage(tc-ts3, 273.15 + 30, 273.15 + 10, tint)
else if (tc<t5) then swage(tc-ts4, 273.15 + 10, 273.15+35, tint)
else 273.15+35




Ti = 310.15
Area = 2.12
V1 = 398400
Ke = 0.116290161
long = L







da = dif0/exp((Ed*(-1 + T0/(Ts + ((Ti - Ts)*x)/L)))/(R*T0))
flux = da*dx(Ca)


initial value
Ca = 0
cp = 0
qtot = 0

equations
Ca: dx(da*dx(Ca)) = dt(Ca)
cp: (Area/V1)*(flux) - Ke*cp = dt(cp)
qtot: dt(qtot) = flux


boundaries
region 1
start(0) point value(Ca) = 0
line to (long) point value(Ca) = Cs0/exp((Es*(-1 + T0/Ts))/(R*T0))

time 0.0 to 48 by 0.01



histories
history(Ca) at (0) (0.002) (0.004) (0.006) (0.008) (0.01) (0.012) (0.014) (0.016) (0.018) (0.02)
history(flux) at (0,long)
history(qtot)
history(cp)
history(Ts)
end
Top of pagePrevious messageNext messageBottom of page Link to this message

Robert G. Nelson (rgnelson)
Moderator
Username: rgnelson

Post Number: 392
Registered: 06-2003
Posted on Wednesday, June 29, 2005 - 08:29 pm:   

1) You should ALWAYS use Monitors to get a picture of what is happening in your problem. Don't just wait til the end and wonder what happened.
When you first set up a problem, it doesn't hurt to take plots of all variables and parameters at "Cycle=1" intervals. After it is working, you can take them out.

2) It appears that by turning off the mesh refinement (with a nodelimit smaller than the initial mesh), you have enforced a large cell at the driven boundary. This cell is not able to resolve the solution when the input flux suddenly jumps, and it goes into an oscillation.

Solution: Remove the nodelimit.

See the attached modification of your problem.
application/octet-stream
problem.pde (1.6 k)

Top of pagePrevious messageNext messageBottom of page Link to this message

Laurent Simon (lsimon)
New member
Username: lsimon

Post Number: 2
Registered: 06-2005
Posted on Thursday, June 30, 2005 - 04:37 am:   

Thank you very much for your quick response.
What a difference!
Laurent

Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action:

Topics | Last Day | Last Week | Tree View | Search | Help/Instructions | Program Credits Administration