How can I import Complex CAD geometry mesh to NREL's Soltrace software by processing mesh through matlab code?

4 visualizaciones (últimos 30 días)
I'm attempting to generate a SolTrace input file from a SolidWorks mesh exported as an STL file. I'm using MATLAB to process the mesh data and create the necessary input for SolTrace. I'm specifically interested in using the stinput format for importing element and stage data.
However, I'm encountering difficulties in correctly formatting the data for SolTrace. Can anyone provide guidance on the specific structure of the stinput file, including the required fields and data types? Additionally, if there are any known compatibility issues between SolidWorks or Ansys STL files and SolTrace's stinput format, please share your experiences.

Respuestas (1)

Umar
Umar el 25 de Sept. de 2024

Hi @yosef futsum ,

You mentioned, “I'm attempting to generate a SolTrace input file from a SolidWorks mesh exported as an STL file. I'm using MATLAB to process the mesh data and create the necessary input for SolTrace. I'm specifically interested in using the stinput format for importing element and stage data. However, I'm encountering difficulties in correctly formatting the data for SolTrace. Can anyone provide guidance on the specific structure of the stinput file, including the required fields and data types? Additionally, if there are any known compatibility issues between SolidWorks or Ansys STL files and SolTrace's stinput format, please share your experiences.”

Please see my response to your comments below.

I did some extensive research for stinput format for SolTrace and found out the documentation seems to be scarced. However, I was able to extract information from the links provided below.

<https://ansyshelp.ansys.com/public/account/secured?returnurl=////////Views/Secured/corp/v242/en/opti_stats_ug/sos_file_format_specs_stl_import_mesh_input_files.html Ansys STL File Information >

<https://www.mathworks.com/help/matlab/ref/stlread.html Mathworks STL function >

<https://www.nrel.gov/docs/fy14osti/59163.pdf Soltrace Documentation >

I got familiar that the stinput format for SolTrace is essential for defining the geometry and stages of your simulation, here are the typical components you should include in your stinput file:

Header Information: This usually includes metadata about the simulation, such as title, author, date, etc.

Element Data

Element Type: This specifies whether you're dealing with a mirror, lens, or other optical elements.

Geometry: You need to define vertices, normals, and connectivity for each triangular facet.

Material Properties: Indicate reflective or absorptive properties for each element.

Stage Data

Stage Type: Define the type of stage (e.g., source, receiver).

Positioning: Specify coordinates and orientation for stages.

Boundary Conditions: If applicable, describe any relevant boundary conditions or environmental factors.

Now, to process your STL file using MATLAB and convert it into the required stinput format, use the `stlread` function to import your STL file:

   [TR, fileformat] = stlread('yourfile.stl');

Then, extract data,the triangulation object TR contains all necessary vertex coordinates and connectivity information.

   vertices = TR.Points; % Nx3 matrix of vertex coordinates
   faces = TR.ConnectivityList; % Mx3 matrix of triangle vertex indices

Construct the stinput structure from the extracted data. An example code snippet could look like this:

   fid = fopen('soltrace_input.stinput', 'w');
   fprintf(fid, 'Title: Your Simulation Title\n');
   % Write Element Data
   for i = 1:size(faces, 1)
       fprintf(fid, 'Element %d: Type=Triangle\n', i);
       fprintf(fid, 'Vertices:\n');
       for j = 1:3
           fprintf(fid, '%f %f %f\n', vertices(faces(i,j), :));
       end
       fprintf(fid, 'End Element\n');
   end
   fclose(fid);

Make sure that your STL files are in ASCII format if there are compatibility issues with binary formats. Also, check for degenerate triangles or invalid geometries that might arise from exporting processes. Now, based on my understanding after reviewing software specifics about SolidWorks and Ansys, both can produce STL files that may include non-manifold edges or other features that SolTrace might not handle well but if you experience problems importing specific STL files into SolTrace, consider simplifying your mesh in SolidWorks before export or use mesh repair tools available in CAD software. If you plan to utilize Mesh OpBefore exporting from SolidWorks, use mesh optimization settings to reduce complexity while retaining necessary detail. I will suggest use tools like MeshLab or Netfabb to validate and repair your STL files before processing them in MATLAB.

Also, try to engage with user forums or communities dedicated to SolTrace who can provide additional insights and shared experiences regarding similar challenges.

Hope this helps answer your questions.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by