-
Notifications
You must be signed in to change notification settings - Fork 94
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
Triangular Prism Geometry for LSC #56
Comments
Hi Tommy, That's a very interesting project, with lots of angles to investigate. I remember Goetzberger studied triangular geometries in one of his early papers, might be worth a look. I don't know how amenable the LSC class is to extension to other geometries, but definitely worth looking in to. It was not something I considered when writing it. The usual pvtrace trace approach is to, define a geometry, material and a light source and to throw rays into the screen and count where they come out. I think you are on the right track starting with Mesh, later down the line you might want to write your own Triangle geometry class to handle the intersections yourself. (Edit) OK, so you have stuff more or less working. But probably I need to see the code to provide useful comments. If you have a fork, post a link to the line in question and the error is gives you. |
No bother at all, I've been working through Jupyter and I'll attach the code below. Apologies if it's a bit messy, I'm picking it up on the fly! Firstly, to create the polygon:
To extrude and visualise the polygon:
Finally, the adapted LSC.py code:
The main changes made to the LSC.py script were in the LSC() class. I removed the size parameter in def_init_, updated the world node as it involved a multiple of the (l, w, d) parameters which no longer exist, and updated the geometry of the LSC node to trimesh.creation.extrude_polygon instead of Box().
The errors appear when I run the above script to run the LSC report. The errors mention things like the self.size parameter in the bauble_radius code, which I assume means it is attached to the size of the LSC box which no longer exists. I've tried tinkering with this but my python knowledge is very limited so I'm not sure where to begin. |
Hi Tommy, I think this an error from the MeshcatRenderer. Baubles are the little spheres that appear on the ray paths when it hits something, they look like Christmas tree decorations hence the (bad) name. Can you put the actual traceback here? But I think the problem is that you are, perhaps, giving pvtrace the trimesh mesh object. You will need to wrap the actual trimesh polygon object with using pvtrace's Mesh class (https://github.com/danieljfarrell/pvtrace/blob/master/pvtrace/geometry/mesh.py). This implement the Geometry protocol so that pvtrace and query the geometry object. So rather than
try,
|
No problem at all, I'll past the traceback here below:
|
And if you change line 1 to be
|
Then it gives this:
Edit: I also tried this input:
Which gave the traceback:
|
What's the type of the
|
It should be a |
It says |
🤔 try and convert that to a trimesh.Trimesh object and it "should just work". |
No bother, I'll give that a go and let you know how I get on! Should I keep using the LSC.py I updated and removed the 'size' parameters, or would I be best to revert back to your original LSC.py script? |
Hi Daniel, Just to give you an update I tried a new approach and it seems to be coming together! Updated the LSC node script to be
I've pasted what appeared in the visualiser after running the new LSC.py script |
Oh looks like it's doing something. Think you solved the initial problem. Nice! |
After updating the air gap to be triangular as well, the visualiser worked however the report gave a new traceback error:
|
This seems to be a common issue with Mesh geometry. It's related to the precision of the intersection points. Cab you define your scene in cm or mm rather than meters? This will make everything bigger so thresholding needs less precision. |
Everything seems to be in working order now, I've attached an image sjowing a quick simulation with 100 rays. My (hopefully!) last question, I was just wondering would you have any idea how I would alter the surfaces in the simulation report? Currently they seem to be (Left, right, top, bottom) as it would be for a box geometry, I imagine I should change the coordinates to have just (left, right, bottom) for mine, with the left and right both being sloped surfaces rather than straight as they would have been in the box.
Thanks a million for all your help this far also! |
Take a look at This assigns labels to the points sitting on the surface. For example, if x-coordinate of the of the point is on the box plane with x=xmin we definite that as being the left surface. Remember you are comparing floats so need to have a tolerance. You will have to come up with a scheme for doing this labelling with your geometry. It will be the same for the edge surfaces and top and bottom, but they hypotenuse will need more of a complicated comparison to evaluate. |
I've taken a look at that piece of code, and updated it to the following. Not sure if it makes sense as I don't recognise the formula or attributes. just been playing around with it until it ran successfully.
The output was as follows:
Seems to be giving "Solar In" values for the left and right surfaces, so something must be incorrect in the way I currently have it written for the "left" and "right" facet labels. |
I'd suggest continuing with your notebook approach, as this it probably a bit too complicated for now. Look at the the Quick Start notebook and others in the examples folder. They show how to throw a ray into the scene and record where it escapes. It too early to make these neat for your geometry. Just get it to work first and then worry about making it simple to use. The LSC.py module was actually the last thing I coded! Assigning positions to facets it actually quite tricky if just relying on the coordinates. I think pvtrace should probably make this easier by retuning an ID. There is a refactor in the works to improve this, but I've been a bit busy the last few years 🥴 |
You might be right! Just giving it a final shot as I feel I could be close enough. At the minute, I'm attmepting to define the equation of the line (y1 and y2) on the left and right hand sides, and defining "left" and "right" as being close to that line.
It doesn't seem to be working as the results aren't adding up, but do you think I could be on the right track with this? Would I be better off trying to define an array of points along the line (the equation of the line is y = 1.4x + 4.666 for the dimensions of my LSC) and using that, and if so how would I do that? I've attached an image from Desmos of the equations of the three lines which make up my triangular geometry. Thanks again, |
Hi Daniel,
Firstly just wanted to say thanks a million for the work you've done on this code, the software is very impressive and easy to follow for a beginner like myself! I was shown your code by a fellow university student, and am hoping to manipulate it to simulate a triangular LSC panel being fabricated for use in a geodesic dome installation as part of my Masters dissertation.
Not an issue as such, but I was hoping to pick your brain as to how you would edit the LSC.py code to work with a triangular prism rather than a box? As I mentioned I am a complete beginner with Python, I have figured out how to extrude a triangular polygon using shapely and trimesh, and have passed light through it using one of your tutorials. I am struggling however to fully adapt the LSC.py code to work with this mesh geometry, specifically as the "size" and "self.size" parameters don't seem to apply to the (polygon, height) input using trimesh.creation.extrude_polygon.
Any help would be greatly appreciated.
Regards,
Thomas.
The text was updated successfully, but these errors were encountered: