Following is copied from the mailing list:
Hi,
First of all, sorry for disappearing for a month or so. Things got really busy with moving and starting school again.
I cloned the latest git repository from [1] and issued a make in the root sfepy directory. Then I ran ./runTests.py and everything passed.
So I tried to run the poisson_parametric_study example and got the following parser exception.:
logan@phoenix:~/projects/sfepy$ ./simple.py input/poisson_parametric_study.py sfepy: left over: ['select_circ', 'vary_omega1_size', 'builtins', 'file', 'output', 'name', 'pause', 'nm', '_filename', 'default_diameter', 'debug', 'os', 'doc'] sfepy: reading mesh (database/square_circ.vtk)...
sfepy: ...done in 0.02 s
sfepy: setting up domain edges...
sfepy: ...done in 0.01 s
sfepy: creating regions... sfepy: leaf Omega region_Omega__2 parsing failed: Struct:Omega_1 name: Omega_1 select: nodes by select_circ( x, y, z, 0.250000 ) Traceback (most recent call last): File "./simple.py", line 100, in <module> main() File "./simple.py", line 93, in main app = SimpleApp( conf, options, output_prefix ) File "/home/logan/projects/sfepy/sfepy/applications/simple_app.py", line 48, in init **kwargs ) File "/home/logan/projects/sfepy/sfepy/fem/problemDef.py", line 83, in from_conf obj.set_regions(conf.regions, conf.materials, obj.functions) File "/home/logan/projects/sfepy/sfepy/fem/problemDef.py", line 124, in set_regions self.domain.create_regions(conf_regions, functions) File "/home/logan/projects/sfepy/sfepy/fem/domain.py", line 589, in create_regions out = bnf.parseString( rdef.select ) File "/usr/lib/pymodules/python2.5/pyparsing.py", line 1076, in parseString raise exc pyparsing.ParseException: Expected end of text (at char 20), (line:1, col:21)
I fired up winpdb and was able to find the exception raised at line 589 in sfepy/fem/domain.py. It looks it isn't parsing the region definition on line 45 of poisson_parametric_study.py:
'Omega_1' : ('nodes by select_circ( x, y, z, %f )' % default_diameter, {}),
The parser fails on the '(' character in the string 'nodes by select_circ( x, y, z, %f )'. Since I'm not familiar yet with pyparsing, that's as far as I can get for now. Does anyone else see this?
Thanks! Logan
[1] : git://git.sympy.org/sfepy.git
And Robert's reply:
Hi Logan,
Logan Sorenson wrote: > Hi, > > First of all, sorry for disappearing for a month or so. Things got really > busy with moving and starting school again.
Same here (no school though, just work).
> I cloned the latest git repository from [1] and issued a make in the root > sfepy directory. Then I ran ./runTests.py and everything passed.
Good, I try to keep the master repo without errors. - Show quoted text -
> So I tried to run the poisson_parametric_study example and got the following > parser exception.: > > logan@phoenix:~/projects/sfepy$ ./simple.py > input/poisson_parametric_study.py > sfepy: left over: ['select_circ', 'vary_omega1_size', 'builtins', > 'file', 'output', 'name', 'pause', 'nm', '_filename', > 'default_diameter', 'debug', 'os', 'doc'] > sfepy: reading mesh > (database/square_circ.vtk)... > > sfepy: ...done in 0.02 > s > > sfepy: setting up domain > edges... > > sfepy: ...done in 0.01 > s > > sfepy: creating regions... > sfepy: leaf Omega region_Omega__2 > parsing failed: Struct:Omega_1 > name: > Omega_1 > select: > nodes by select_circ( x, y, z, 0.250000 ) > Traceback (most recent call last): > File "./simple.py", line 100, in <module> > main() > File "./simple.py", line 93, in main > app = SimpleApp( conf, options, output_prefix ) > File "/home/logan/projects/sfepy/sfepy/applications/simple_app.py", line > 48, in init > **kwargs ) > File "/home/logan/projects/sfepy/sfepy/fem/problemDef.py", line 83, in > from_conf > obj.set_regions(conf.regions, conf.materials, obj.functions) > File "/home/logan/projects/sfepy/sfepy/fem/problemDef.py", line 124, in > set_regions > self.domain.create_regions(conf_regions, functions) > File "/home/logan/projects/sfepy/sfepy/fem/domain.py", line 589, in > create_regions > out = bnf.parseString( rdef.select ) > File "/usr/lib/pymodules/python2.5/pyparsing.py", line 1076, in > parseString > raise exc > pyparsing.ParseException: Expected end of text (at char 20), (line:1, > col:21) > > I fired up winpdb and was able to find the exception raised at line 589 in > sfepy/fem/domain.py. It looks it isn't parsing the region definition on line > 45 of poisson_parametric_study.py: > > 'Omega_1' : ('nodes by select_circ( x, y, z, %f )' % default_diameter, {}), > > The parser fails on the '(' character in the string 'nodes by select_circ( > x, y, z, %f )'. Since I'm not familiar yet with pyparsing, that's as far as > I can get for now. Does anyone else see this?
Thanks for the bug-report! This input file is not covered by the tests, and it should. Could you submit an issue at [1]? It is also easy to fix, see below.
The error you see is related to implementing the issues 36 and 93, [2,3], i.e. a unification of passing (extra) arguments to BC, material, and region definition functions. There is now a new keyword 'functions', where a function to be used should be registered, and any extra parameters are handled there too. The function is then used by its name only, see, for example, input/octahedron.py (or "git grep 'functions =" to see all the inputs using this feature).
Would you like to try and fix it yourself?
cheers, r.
[1] http://code.google.com/p/sfepy/issues/list [2] http://code.google.com/p/sfepy/issues/detail?id=36&can=1 [3] http://code.google.com/p/sfepy/issues/detail?id=93&can=1
Comment #1
Posted on Sep 30, 2009 by Massive HippoHi Robert,
Thanks for your input! I attempted to fix the poisson_parametric_study.py per your suggestions. Please find the updated file attached.
However, now I am encountering what I believe to be a separate issue with the poisson_parametric_study.py input file. I'm getting the following output:
logan@phoenix:~/projects/sfepy$ ./simple.py input/poisson_parametric_study_20090930.py
sfepy: left over: ['select_circ', 'vary_omega1_size', 'builtins', 'file', 'output', 'name', 'pause', 'nm', '_filename', 'default_diameter', 'debug', 'os', 'doc'] sfepy: reading mesh (database/square_circ.vtk)...
sfepy: ...done in 0.01 s
sfepy: setting up domain edges...
sfepy: ...done in 0.00 s sfepy: creating regions... sfepy: leaf Omega region_Omega__2 sfepy: leaf Omega_1 region_Omega_1__1 sfepy: leaf Gamma_1 region_Gamma_1__0 sfepy: leaf Gamma_2 region_Gamma_2__3 sfepy: ...done in 0.03 s Traceback (most recent call last): File "./simple.py", line 100, in main() File "./simple.py", line 93, in main app = SimpleApp( conf, options, output_prefix ) File "/home/logan/projects/sfepy/sfepy/applications/simple_app.py", line 48, in init **kwargs ) File "/home/logan/projects/sfepy/sfepy/fem/problemDef.py", line 83, in from_conf obj.set_regions(conf.regions, conf.materials, obj.functions) File "/home/logan/projects/sfepy/sfepy/fem/problemDef.py", line 126, in set_regions materials = Materials.from_conf(conf_materials, functions) File "/home/logan/projects/sfepy/sfepy/fem/materials.py", line 27, in from_conf fun = functions[fun] File "/home/logan/projects/sfepy/sfepy/base/base.py", line 241, in getitem raise IndexError IndexError
It seems like the problem is that sfepy is erroneously looking for a function to set the material parameters. Are the material parameters in poisson_parametric_study.py the correct format?
Also, the from_conf method in sfepy/fem/materials.py beginning on line 9 may have an error:
def from_conf(conf, functions, wanted=None):
"""Construct Materials instance from configuration."""
if wanted is None:
wanted = conf.keys()
objs = OneTypeList(Material)
for key, mc in conf.iteritems():
if key not in wanted: continue
fun = get_default_attr(mc, 'function', None)
vals = get_default_attr(mc, 'values', None)
if (fun is not None) and (vals is not None):
msg = 'material can have function or values but not both! (%s)' \
% mc
raise ValueError(msg)
elif vals is not None: # => fun is None
fun = ConstantFunction(vals, functions = functions)
else: # => vals is None
fun = functions[fun]
if (fun is None):
msg = 'material has no values! (%s)' % mc
raise ValueError(msg)
For some reason, with this input file, fun == None and val == None, so an IndexError exception is raised in the else clause for fun = functions[fun].
I'll have another look later on, but I wanted to give an update of the progress.
Thanks! Logan
Comment #2
Posted on Oct 5, 2009 by Massive HippoClosing this issue. The problem should be fixed from commit id 7b310b6c5e5097b40f990afc890334d481431489 onwards.
Logan
Comment #3
Posted on Jan 30, 2012 by Massive HippoMigrated to http://github.com/sfepy/sfepy/issues/100
Status: Migrated