MoDeNa-EUProject / MoDeNa

Software Framework for MOdelling of morphology DEvelopment of micro- and NAnostructures (MoDeNa)
17 stars 19 forks source link

Bug in argPos for functions with index set inputs #70

Closed japaf closed 8 years ago

japaf commented 8 years ago

I tried to add one more component to gasConductivity index set (species), but gasMixtureConductivity model is then not created correctly in the database.

How to reproduce on my branch aging go to applications/PUfoam/foamAging, then

./build
cp example_inputs/foamConductivity.in .
./foamCond

What should hapen At the beggining of the model output, I print out the value of x_size - number of species as seen in gasMixtureConductivity surrogate model. It should be 4 (as defined in gasConductivity.py), and not 3.

I had to disable modena_model_argPos_check to get this output, otherwise I get error

argPos 8 not used
japaf commented 8 years ago

I noticed that the gasMixutureConductivity is sometimes not even evaluated, because the Modena framework thinks the model is "out of bounds". The output is then

Performing backward mapping simulation (macroscopic code recipe)
 Welcome in hahtf
 ok
 ok
return code = 200
Model out-of-bounds, executing outOfBoundsStrategy.
Traceback (most recent call last):
  File "/home/pavel/lib/python2.7/site-packages/modena/Strategy.py", line 940, in outOfBounds
    wf = model.outOfBoundsStrategy().workflow(
  File "/home/pavel/lib/python2.7/site-packages/modena/SurrogateModel.py", line 1073, in __getattribute__
    return super(SurrogateModel, self).__getattribute__(name)
AttributeError: 'ForwardMappingModel' object has no attribute 'outOfBoundsStrategy'
2016-02-01 13:25:51,993 INFO Task completed: {{modena.Strategy.BackwardMappingScriptTask}} 
2016-02-01 13:25:52,014 INFO Rocket finished

However, executing ./foamCond once more produces:

Welcome in hahtf
 ok
 ok
x_size: 3 
0.0158781 0.0121648 0.0251313 
 System information:
  higher temperature: 2.840E+02 K
  lower temperature:  2.820E+02 K
 Phase properties:
  gas conductivity:   1.470E+01 mW/m/K
  solid conductivity: 2.071E+02 mW/m/K
 Foam morphology:
  porosity: 0.968E+00
  foam density: 0.354E+02 kg/m^3
  cell size: 0.510E+03 um
  wall thickness: 0.255E+01 um
  strut content: 0.626E+00
  strut diameter: 0.304E+02 um
 TESTING: radiative properties not calculated.
 Ask Pavel if you want more reasonable results.
 Conduction:
  effective conductivity: 1.798E+01 mW/m/K
  equivalent conductivity: 1.998E+01 mW/m/K
  contribution of gas: 7.230E+01 %
  contribution of solid: 1.769E+01 %
  contribution of radiation: 1.001E+01 %
Success - We are done
2016-02-01 13:25:55,723 INFO Task completed: {{modena.Strategy.BackwardMappingScriptTask}} 
2016-02-01 13:25:55,765 INFO Rocket finished

That means the surrogate gasMixutureConductivity model was evaluated, but x_size was 3 (even though the index set was defined with 4 species: [ 'CO2', 'CyP', 'O2', 'N2' ]). Sometimes, it is necessary to run ./foamCond several times to get this result. I am not sure why the framework sometimes thinks the model is "out of bounds" and sometimes not even though the input is always the same.

japaf commented 8 years ago

I updated the aging branch to the latest commit on upstream/nextRelease but the problem is unchanged. Henrik, can you please have a look?

henrus commented 8 years ago

Hi Pavel,

I will start with the 'argPos not found' issue and I can see 'japaf/aging'

But I cannot find 'upstream/nextRelease' in your private repo. The choice seems to be:

henrus@andermatt:~/projects/Modena/MoDeNa-github$ git branch -a | egrep japaf remotes/japaf/aging remotes/japaf/fcond remotes/japaf/frecon remotes/japaf/gasmix remotes/japaf/gh-pages remotes/japaf/karimimp/nextRelease remotes/japaf/kinet remotes/japaf/master remotes/japaf/modelModules remotes/japaf/nextRelease remotes/japaf/recon remotes/japaf/solub remotes/japaf/substituteModels2 remotes/japaf/work

Henrik

japaf commented 8 years ago

Hello Henrik,

I expressed myself inaccurately. The issue is located in "remotes/japaf/aging". If you want to see the message argPos 8 not used then uncomment line 78 in https://github.com/japaf/MoDeNa/blob/aging/applications/PUfoam/MoDeNaModels/foamConductivity/src/src/physicalProperties.f90. Otherwise, you should see the output as in my last message, where x_size is 3, but should be 4. This is printed from the C code of the surrogate gasMixtureConductivity model.

Pavel

henrus commented 8 years ago

The size issue was a stupid bug which I fixed in f17bd99. Does it fix this issue entirely?

japaf commented 8 years ago

Unfortunately no. The modena_model_argPos_check(kgasModena) still fails. If I disable it, I can now access the fourth gas conductivity in gasMixtureConductivity C code correctly (the input from substitute models), but the fourth composition input (x[A=N2], actual input from my code) is just some random number.

henrus commented 8 years ago

Ok. I pushed a second bugfix installment - same error different place. This fixes the check. Can you please check whether it fixes the misaligned read?

japaf commented 8 years ago

Excellent, it works in 162824733c75734b5dfe24c64b387142ff342fe9. Thank you very much. Closing the issue.