Hi to all
Here is the following excerpt of my .sif file
Constants
Unit Charge = 1.602e-19
End
$q = 1.602e-19
Body Force 1
Name = "BodyForce 1"
Charge Density = elfield
Real MATC "1.602e-19*tx"
End
Solver 1
Equation = "Poisson"
Variable = "Potential"
Variable DOFs = 1
Procedure = "StatElecSolve" "StatElecSolver"
Calculate Electric Field = True
Calculate Electric Flux = False
Linear System Solver = "Direct"
Steady State Convergence Tolerance = 1e-06
End
Running the above is OK. However, now replace
Real MATC "1.602e-19*tx"
by
Real MATC "Unit Charge*tx"
and I get
ERROR:: Model Input: Unknown specifier: []
at the MATC line
If instead I replace by
Real MATC "$q*tx"
I get
Solver input file error: MATC ERROR: String not terminated.
Therefore, I am not sure if Elmer is capable of replacing numbers by constant names in a MATC expression
Have a nice weekend
Constant names in matc expressions
-
- Site Admin
- Posts: 4832
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Constant names in matc expressions
Hi
matc is a poor mans matlab that evaluates mathematical expressions. You can evoke in in two ways
a) using the dollar sign it evaluates the epression in-line when parsing the sif file
b) using the MATC environment it evaluates expression again always when needed to evaluate a keyword
Because "$" and "MATC" effictively use the same library to evaluate stuff you don't need to reintroduce the environment. When you say "$q=..." the value of "q" is available also there when evaluting the "MATC" expressions. Hence the syntax that works is
The keywords such as "Charge Density" are available only as list entries in the Model stucture. matc environment does not know anything about them.
If you look at sif files you may often see that the are many constants defined using "$" sign. This allows the user to collect the most common parameters to change in the start of the sif file.
-Peter
matc is a poor mans matlab that evaluates mathematical expressions. You can evoke in in two ways
a) using the dollar sign it evaluates the epression in-line when parsing the sif file
b) using the MATC environment it evaluates expression again always when needed to evaluate a keyword
Because "$" and "MATC" effictively use the same library to evaluate stuff you don't need to reintroduce the environment. When you say "$q=..." the value of "q" is available also there when evaluting the "MATC" expressions. Hence the syntax that works is
Code: Select all
Charge Density = Variable "elfield"
Real MATC "q*tx"
If you look at sif files you may often see that the are many constants defined using "$" sign. This allows the user to collect the most common parameters to change in the start of the sif file.
-Peter
Re: Constant names in matc expressions
Actually
Charge Density = elfield
was a typo in my thread. In the code, I had written
Charge Density = Variable elfield
and
Print *, "voltage is ", GetVarName( Solver % Variable)
will display elfield
the same thing happens, if instead of the above, I write
Charge Density = Variable "elfield"
However with
Charge Density = Variable 'elfield'
'elfield' is displayed
Unfortunately,
$q = 1.602e-19
........
Charge Density = Variable "elfield"
Real MATC "q*tx"
still results in
unknown specifier: [charge density]
Therefore, I will pass constant and functions of them into a solver's main variables or its exported variables
Charge Density = elfield
was a typo in my thread. In the code, I had written
Charge Density = Variable elfield
and
Print *, "voltage is ", GetVarName( Solver % Variable)
will display elfield
the same thing happens, if instead of the above, I write
Charge Density = Variable "elfield"
However with
Charge Density = Variable 'elfield'
'elfield' is displayed
Unfortunately,
$q = 1.602e-19
........
Charge Density = Variable "elfield"
Real MATC "q*tx"
still results in
unknown specifier: [charge density]
Therefore, I will pass constant and functions of them into a solver's main variables or its exported variables
Re: Constant names in matc expressions
Sorry but I should written something like
Charge Density = Variable UnitCharge, Electron Field 1,.....
where UnitCharge is a global variable and Electron Field 1 is one dimensional
since elfield is 2 or 3 dim variable and that is illegal
Charge Density = Variable UnitCharge, Electron Field 1,.....
where UnitCharge is a global variable and Electron Field 1 is one dimensional
since elfield is 2 or 3 dim variable and that is illegal