Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting transition position XTR does not work #25

Open
morihab opened this issue Mar 24, 2023 · 4 comments
Open

Setting transition position XTR does not work #25

morihab opened this issue Mar 24, 2023 · 4 comments

Comments

@morihab
Copy link

morihab commented Mar 24, 2023

Hi there,
first of all, it`s really great to have this module.
I tried to set the transition position, but got the following error:

`>>> xf.xtr((1.0, 0.95))
Traceback (most recent call last):
File "", line 1, in
File "/home/moritz/.local/lib/python3.10/site-packages/xfoil/xfoil.py", line 126, in xtr
return float(xtr_top), float(xtr_bot)
ValueError: could not convert string to float: c_float(1.0)

`
I used the included naca0012 airfoil.

Thanks in advance,
Moritz

@time-trader
Copy link

To start with, the proper way to assign the property is:
xf.xtr = (1.0, 0.95)

But you are right that there is problem on the property side of the wrapper (not on the setter).

What is happening:

You are setting xtr as a c_float type using ctypes package, so python float -> c_float, but python seems to have a problem converting c_float back to float.
In particular in

return float(xtr_top), float(xtr_bot)

That line should be changed to:
return xtr_top.value, xtr_bot.value
This will fix the problem, I will make a pull request for that.

For now you can set xtr like this:
xf.xtr = (1.0, 0.95)

Your code will run, and the wrapper will set xtr values for xfoil solver. But if you try to access the xf.xtr property from python code you will still get the error, until next PR.

BTW, check out https://github.com/aerosense-ai/panel-codes-service wrapper to run xfoil as a service (locally or on your own server/cloud). The service takes inputs and configurations as JSON files and produces JSON outputs.

@morihab
Copy link
Author

morihab commented Apr 7, 2023

Thank you very much for the reply! Setting the transition position the way you described works. I had the same idea of changing float(xtr_top) to xtr_top.value but after changing it other errors popped up and I was somehow stuck.

aerosense ai looks very promising, will look into it, thanks for the hint!

@timjim333
Copy link

Thanks for posting the query and thanks for the solution hint! I had this problem a few months ago too, but never had time (or ctypes wrapping knowledge) to debug it.

I'll try this out and report back, unless a PR will go through soon? Thanks.

@time-trader
Copy link

@timjim333 I have not managed to get in contact with the repo authors / maintainers. Will probably fork, for more active development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants