SaveLine: simulation time in output file

Numerical methods and mathematical models of Elmer
Post Reply
tomatoma
Posts: 12
Joined: 12 Feb 2016, 23:04
Antispam: Yes

SaveLine: simulation time in output file

Post by tomatoma »

Dear All,

First of all let me thank and congratulate all people that contribute to this great project and forum! :)

I am carrying out a transient simulation (elmer 8.1, copper slab with constant temperature on one side and constant heat flux on the opposite side).
I'd like to include the simulation time in a column of the SaveLine output file.
It works in SaveScalars, but it does not seem to work in SaveLine.
What am I doing wrong? :?
Here is my sif file:

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "."
  Include Path ""
  Results Directory ""
End

Simulation
  Max Output Level = 6
  Coordinate System = Cartesian
  Coordinate Mapping(3) = 1 2 3
  Simulation Type = Transient
  Steady State Max Iterations = 1
  Output Intervals = 1
  !Timestep intervals = 200
  !Timestep sizes = 0.001
  !Timestepping Method = BDF
  
  ! Simulation steps are logarithmically spaced between tstart and tstop.
  $tstart = 1e-5
  $tstop  = 0.2
  $nsteps = 260
  $q=(tstop/tstart)^(1/(nsteps-1))
  Timestep Intervals = $ nsteps
  Timestep Size = Variable TimeStep
    Real MATC "if (tx==1) tstart; else tstart*(q^(tx-1)-q^(tx-2));"
  
  BDF Order = 1
  Solver Input File = case.sif
  Post File = case.ep
Coordinate scaling = 0.001
End

Constants
  Gravity(4) = 0 -1 0 9.82
  Stefan Boltzmann = 5.67e-08
  Permittivity of Vacuum = 8.8542e-12
  Boltzmann Constant = 1.3807e-23
  Unit Charge = 1.602e-19
End

Body 1
  Target Bodies(1) = 1
  Name = "Body 1"
  Equation = 1
  Material = 1
  Initial condition = 1
End

Solver 1
  Equation = Heat Equation
  Procedure = "HeatSolve" "HeatSolver"
  Variable = Temperature
  Exec Solver = Always
  Stabilize = True
  Bubbles = False
  Lumped Mass Matrix = False
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 20
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1
  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = Diagonal
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 1
  Linear System Precondition Recompute = 1
End


! http://www.elmerfem.org/forum/viewtopic.php?f=8&t=478&p=3788&hilit=add+solver+elmergui&sid=7890dfa87169c038b2f9f93e2dc2ac64#p3788
Solver 2
  Procedure = "SaveData" "SaveScalars"
  Exec solver = after timestep
  FileName = "file.dat"
  Save Coordinates(2,2) =   1e-3 0.0 0.0 0.0
  Exact Coordinates = True
  Variable 1 = Time
  Variable 2 = Temperature
End

Solver 3
  Exec solver = after timestep
  Procedure = "SaveData" "SaveLine"
  FileName = "fileLine.dat"
  Polyline Coordinates(2,2) = -1e-3 0.0 1e-3 0.0
  Variable 1 = Time
  Variable 2 = Coordinate 1
  Variable 3 = Temperature
End

Equation 1
  Name = "Equation 1"
  Active Solvers(3) = 1 2 3  ! not sure whether or not I have to include solvers 2 and 3 here
End

Material 1
  Name = "Copper (generic)"
  Heat Conductivity = 401.0
  Youngs modulus = 115.0e9
  Mesh Poisson ratio = 0.34
  Heat Capacity = 385.0
  Density = 8960.0
  Poisson ratio = 0.34
  Sound speed = 3810.0
  Heat expansion Coefficient = 16.5e-6
End

Initial Condition 1
  Name = "Tinitial"
  Temperature = 300
End

Boundary Condition 1
  Target Boundaries(1) = 1 
  Name = "HeatFlux"
  Heat Flux = 130000
  !Save Scalars = Logical True
End

Boundary Condition 2
  Target Boundaries(1) = 3 
  Name = "Tconst"
  Temperature = 300
End
Here are the first few lines of file.dat:

Code: Select all

1.000000000000E-005   3.000110099037E+002   1.000000000000E-003   1.365876248131E-022   0.000000000000E+000   3.000000000000E+002  -3.388131789017E-021  -1.694065894509E-021   0.000000000000E+000
1.038977860767E-005   3.000113739571E+002   1.000000000000E-003   1.365876248131E-022   0.000000000000E+000   3.000000000000E+002  -3.388131789017E-021  -1.694065894509E-021   0.000000000000E+000
1.079474995165E-005   3.000117182950E+002   1.000000000000E-003   1.365876248131E-022   0.000000000000E+000   3.000000000000E+002  -3.388131789017E-021  -1.694065894509E-021   0.000000000000E+000
1.121550621228E-005   3.000120526811E+002   1.000000000000E-003   1.365876248131E-022   0.000000000000E+000   3.000000000000E+002  -3.388131789017E-021  -1.694065894509E-021   0.000000000000E+000
1.165266265186E-005   3.000123816918E+002   1.000000000000E-003   1.365876248131E-022   0.000000000000E+000   3.000000000000E+002  -3.388131789017E-021  -1.694065894509E-021   0.000000000000E+000
1.210685851427E-005   3.000127076582E+002   1.000000000000E-003   1.365876248131E-022   0.000000000000E+000   2.999999999999E+002  -3.388131789017E-021  -1.694065894509E-021   0.000000000000E+000
1.257875795977E-005   3.000130322166E+002   1.000000000000E-003   1.365876248131E-022   0.000000000000E+000   2.999999999999E+002  -3.388131789017E-021  -1.694065894509E-021   0.000000000000E+000
[/size]
where the simulation times correctly appear in the first column.

Here are the first few lines of the fileLine.dat:

Code: Select all

     1     1   1    1028                 NaN -1.00000000000E-003  3.00000000000E+002
     1     1   1     502  2.32433815490E-316  1.00000000000E-003  3.00011009904E+002
     1     1   1    1901  3.00004110790E+002  9.90944169176E-004  3.00008433612E+002
     1     1   1    1101  1.45102687160E+002 -8.25777344381E-004  3.00000000000E+002
     1     1   1    2900  2.80422350800E+002 -6.64701004102E-004  3.00000000000E+002
     1     1   1    2900  3.00001252115E+002 -6.53437643781E-004  3.00000000000E+002
     1     1   1    3039  3.00007346218E+002  9.83196589635E-004  3.00006747120E+002
     1     1   1    3039  3.00008243134E+002  9.81748347310E-004  3.00006435147E+002
[/size]
and the content of fileLine.dat.names:

Code: Select all

Variables in file: ./fileLine.dat
File started at: 2016/02/28 21:52:43
      0 boundary nodes for each step
     53 polyline nodes for each step
  1: Time step
  2: Iteration step
  3: Boundary condition
  4: Node index
  5: time
  6: coordinate 1
  7: temperature
The values in the 5th column of fileLine.dat do not correspond to the simulation times (not sure what they represent instead). :(

Thanks,
Best regards,
Matteo
tomatoma
Posts: 12
Joined: 12 Feb 2016, 23:04
Antispam: Yes

Re: SaveLine: simulation time in output file

Post by tomatoma »

Hi All,

Elmer 8.2 gives the same results.
Column 5 of the output file generated by "SaveLine" (fileLine.dat in my example) does not contain the time. Not sure what it contains.

Anyone can help?

Thanks,
Best regards,
Matteo
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: SaveLine: simulation time in output file

Post by raback »

Hi

You seem to request for "time" in SaveLine but as time is a single value it fails. The SaveLine is intended for distributed values that vary over the line.

The "timestep" is provided as an integer so that you could pick values related to particular timestep by Matlab, for example, using

Code: Select all

! plot temperature curve of i:th timestep
ind=find(f(:,1)==i);
plot(f(ind,6),f(ind,7));
If you want to know the time related to given timestep you could easily fecth it from the table saved byt SaveScalars from the i:th row.

-Peter
tomatoma
Posts: 12
Joined: 12 Feb 2016, 23:04
Antispam: Yes

Re: SaveLine: simulation time in output file

Post by tomatoma »

Hi,

I was indeed interested in including the time in the SaveLine output file.
I was expecting the solver to stamp the same time value for every point along the polyline, for each time step. The time of each step would then be available in the SaveLine output file, although repeated n times for each step, where n is the number of points along the polyline.
As you said, and as I did, one workaround is to include the time in the output file of SaveScalars.

Thanks,
Best regards,
Matteo
Post Reply