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

TypeErrors - Tutorial Examples #88

Closed
MostafaMohamed2023 opened this issue Jul 31, 2023 · 11 comments · Fixed by #89
Closed

TypeErrors - Tutorial Examples #88

MostafaMohamed2023 opened this issue Jul 31, 2023 · 11 comments · Fixed by #89
Assignees

Comments

@MostafaMohamed2023
Copy link

Hi,

My name is Mostafa Mohamed and am a graduate student at Arizona State University.
I am reporting this bug as follows: the error appears:
"TypeError: FigureBase.gca() got an unexpected keyword argument 'projection'"

Thanks in advance for any help!

Regards,
Mostafa

@kip-hart kip-hart self-assigned this Aug 1, 2023
@kip-hart
Copy link
Owner

kip-hart commented Aug 1, 2023

Hi Mostafa,

Thanks for reaching out with this bug report. I believe matplotlib updated 3D graphics since I last wrote the code. It looks like this is the particular error: https://stackoverflow.com/questions/67095247/gca-and-latest-version-of-matplotlib.

I'll take a look in the next week at fixing this. If you need to use MicroStructPy in the meantime, you could use a virtual environment with a version of matplotlib from 2020 and it should work in there.

Best,
Kip

@MostafaMohamed2023
Copy link
Author

Thanks for your help!
I followed up scripts to modify it, and it is working now.
Could you please help me to get the output format for Abaqus where I tried to change "format = 'abaqus' " at trimesh.py, but it didn't work?

Regards,

@kip-hart
Copy link
Owner

kip-hart commented Aug 4, 2023

Hi Mostafa,

I'm glad the script is working now. Sorry there's an issue with using abaqus file format. What about it didn't work? Could you post a script that produces the error?

Best,
Kip

@MostafaMohamed2023
Copy link
Author

Hi Kip,

Thanks for your prompt response.
No change happened when I changed the format to be in the output file for Abaqus. That's what "it didn't work" means.
So, is there any way to get geometry and mesh files to work with Abaqus?

Regards,
Mostafa

@kip-hart
Copy link
Owner

kip-hart commented Aug 4, 2023

Hi Mostafa,

Could you clarify whether you changed the source code for trimesh.py or you changed the input keyword argument to an instance of the class?

Showing me some of the code would help.

Best,
Kip

https://github.com/kip-hart/MicroStructPy/blob/master/src/microstructpy/meshing/trimesh.py#L262

@MostafaMohamed2023
Copy link
Author

Hi Kip,

The main objective is to execute this example: https://docs.microstructpy.org/en/latest/examples/cli/basalt.html
So, I did it as provided, then I have started getting the output file in Abaqus output format.

I have changed the input keyword argument at trimesh.py; the Abaqus input file option, format='abaqus' in [TriMesh.write()].
From being:
def write(self, filename, format='txt', seeds=None, polymesh=None):
to be:
def write(self, filename, format='abaqus', seeds=None, polymesh=None):

But, there is no change happened.
I used the following link:
(https://docs.microstructpy.org/en/latest/api/meshing/trimesh.html#microstructpy.meshing.TriMesh.write),

Regards,
Mostafa

@kip-hart
Copy link
Owner

kip-hart commented Aug 4, 2023

Hi Mostafa,

Thanks for the explanation. Please change the write function back to format='txt' in the source code. Instead, you can create abaqus inp files by adding <tri> abaqus </tri> to the filetypes settings, since the default is txt. There's an explanation for the input settings on this page: https://docs.microstructpy.org/en/latest/cli/settings.html#filetypes

Try this input file and see if it writes the trimesh to an abaqus inp file:

<?xml version="1.0" encoding="UTF-8"?>
<input>
    <material>
        <name> Plagioclase </name>
        <fraction>
            <dist_type> norm </dist_type>
            <loc> 45.2 </loc>
            <scale> 0.2 </scale>
        </fraction>
        <size>
            <dist_type> cdf </dist_type>
            <filename> aphanitic_cdf.csv </filename>
        </size>
        <color> #BDBDBD </color>
    </material>

    <material>
        <name> Olivine </name>
        <shape> ellipse </shape>
        <fraction>
            <dist_type> norm </dist_type>
            <loc> 19.1 </loc>
            <scale> 0.2 </scale>
        </fraction>
        <size>
            <dist_type> cdf </dist_type>
            <filename> olivine_cdf.csv </filename>
        </size>
        <aspect_ratio>
            <dist_type> uniform </dist_type>
            <loc> 1.0 </loc>
            <scale> 2.0 </scale>
        </aspect_ratio>
        <angle_deg>
            <dist_type> uniform </dist_type>
            <loc> -90 </loc>
            <scale> 180 </scale>
        </angle_deg>
        <color> #99BA73 </color>
    </material>

    <material>
        <name> Diopside </name>
        <fraction>
            <dist_type> norm </dist_type>
            <loc> 13.2 </loc>
            <scale> 0.2 </scale>
        </fraction>
        <size>
            <dist_type> cdf </dist_type>
            <filename> aphanitic_cdf.csv </filename>
        </size>
        <color> #709642 </color>
    </material>

    <material>
        <name> Hypersthene </name>
        <fraction>
            <dist_type> norm </dist_type>
            <loc> 16.6 </loc>
            <scale> 0.2 </scale>
        </fraction>
        <size>
            <dist_type> cdf </dist_type>
            <filename> aphanitic_cdf.csv </filename>
        </size>
        <color> #876E59 </color>
    </material>

    <material>
        <name> Magnetite </name>
        <fraction>
            <dist_type> norm </dist_type>
            <loc> 3.35 </loc>
            <scale> 0.2 </scale>
        </fraction>
        <size>
            <dist_type> cdf </dist_type>
            <filename> aphanitic_cdf.csv </filename>
        </size>
        <color> #6E6E6E </color>
    </material>

    <material>
        <name> Chromite </name>
        <fraction>
            <dist_type> norm </dist_type>
            <loc> 0.65 </loc>
            <scale> 0.2 </scale>
        </fraction>
        <size>
            <dist_type> cdf </dist_type>
            <filename> aphanitic_cdf.csv </filename>\
        </size>
        <color> #545454 </color>
    </material>

    <material>
        <name> Ilmenite </name>
        <fraction>
            <dist_type> norm </dist_type>
            <loc> 0.65 </loc>
            <scale> 0.2 </scale>
        </fraction>
        <size>
            <dist_type> cdf </dist_type>
            <filename> aphanitic_cdf.csv </filename>
        </size>
        <color> #6B6B6B </color>
    </material>

    <material>
        <name> Apatite </name>
        <fraction>
            <dist_type> norm </dist_type>
            <loc> 3.35 </loc>
            <scale> 0.2 </scale>
        </fraction>

        <size>
            <dist_type> cdf </dist_type>
            <filename> aphanitic_cdf.csv </filename>
        </size>
        <color> #ABA687 </color>
    </material>

    <domain>
        <shape> circle </shape>
        <diameter> 10 </diameter>
    </domain>

    <settings>
        <directory> basalt_circle </directory>
        <filetypes>
            <seeds_plot> png </seeds_plot>
            <poly_plot> png </poly_plot>
            <tri> abaqus </tri>   <!-- this is where trimesh output file type is specified --> 
            <tri_plot> png </tri_plot>
            <verify_plot> png </verify_plot>
        </filetypes>

        <plot_axes> False </plot_axes>
        <verbose> True </verbose>
        <verify> True </verify>

        <mesh_max_edge_length> 0.01 </mesh_max_edge_length>
        <mesh_min_angle> 20 </mesh_min_angle>
        <mesh_max_volume> 0.05 </mesh_max_volume>

        <seeds_kwargs>
            <linewidths> 0.2 </linewidths>
        </seeds_kwargs>
        <poly_kwargs>
            <linewidths> 0.2 </linewidths>
        </poly_kwargs>
        <tri_kwargs>
            <linewidths> 0.1 </linewidths>
        </tri_kwargs>
    </settings>
</input>

@MostafaMohamed2023
Copy link
Author

Thank you for explaining everything so well.
I'm trying to run this script, but even when I run it at a small sample size, it takes a long time.
I'll let you know if I find anything new.

Regards,
Mostafa

@MostafaMohamed2023
Copy link
Author

Hi Kip,

Sorry for confusion, but I got an Abaqus input file.

Thank you very much for your patience and consideration.

Regards,
Mostafa

@kip-hart
Copy link
Owner

kip-hart commented Aug 7, 2023

Hi Mostafa,

The issue with TypeErrors has been resolved and I've updated microstructpy to v1.5.7. If you upgrade to the latest, that issue will be fixed. Feel free to reopen or submit another ticket if you have any other issues.

Best,
Kip

@MostafaMohamed2023
Copy link
Author

Hi Kip,

We really appreciate the knowledge. Sure, I'll let you know if I have any questions.

Regards,
Mostafa

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

Successfully merging a pull request may close this issue.

2 participants