bessagroup/CRATE

encoding issues when running the benchmark

Closed this issue · 3 comments

Hi! I tried to install and run this package on a fresh conda env:

$ conda create --name crate pip
$ conda activate crate
$ pip install -U cratepy
$ python benchmarks/run_crate_benchmark.py

However, I had these strange "xx m" and errors:

←[37m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~←[0m←[37m
                  CRATE - Clustering-based Nonlinear Analysis of Materials

                              Created by Bernardo P. Ferreira

                                  Release 1.0.0 (Jun 2023)

←[33mProblem under analysis: ←[0mexample_1_uniaxial_tension_nc54

←[33mInput data file: ←[0mexample_1_uniaxial_tension_nc54.dat

←[33mStarting program execution at: ←[0m08h24m11s (16/Jul/2023)
←[37m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~←[0m

←[37m--------------------------------------------------------------------------------------------←[0m
←[32mStart phase: ←[37mRead input data file
←[0m

  > Reading the input data file...

  > Reading discretization file...

  > Storing problem general data...

  > Storing material data...

  > Storing macroscale loading data...

  > Storing regular grid data...

  > Storing clustering data...

  > Storing self-consistent scheme data...

  > Storing algorithmic data...

  > Storing VTK output data...

  > Storing general output files data...
←[32m

End phase: ←[37mRead input data file (phase duration time = 5.95e-01s)
--------------------------------------------------------------------------------------------←[0m
←[32mStart phase: ←[37mCompute clustering features data matrix
←[0m

  > Setting cluster analysis' features...

  > Computing RVE local elastic strain response database...

    > Macroscale strain loading (1 of 3)...

    > Macroscale strain loading (2 of 3)...

    > Macroscale strain loading (3 of 3)...

  > Computing cluster analysis global data matrix...

  > Standardizing cluster analysis global data matrix...
←[32m

End phase: ←[37mCompute cluster analysis data matrix (phase duration time = 3.45e+00s)
--------------------------------------------------------------------------------------------←[0m
←[32mStart phase: ←[37mPerform RVE cluster analysis
←[0m

  > Computing CRVE base clustering...

    > Computing material phase 1 base clustering...

    > Computing material phase 2 base clustering...

    > Computing CRVE base clustering descriptors...

  > Writing clustering VTK file...
←[32m

End phase: ←[37mPerform RVE cluster analysis (phase duration time = 1.52e+01s)
--------------------------------------------------------------------------------------------←[0m
←[32mStart phase: ←[37mCompute CRVE cluster interaction tensors
←[0m

  > Computing CRVE cluster interaction tensors...
←[32m

End phase: ←[37mCompute cluster interaction tensors (phase duration time = 9.75e+01s)
--------------------------------------------------------------------------------------------←[0m
←[32mStart phase: ←[37mSolve reduced microscale equilibrium problem
←[0m

←[35m  ******************************************************************************************
  VTK Output: ←[0mWriting increment VTK output file...
←[35m  ******************************************************************************************←[0m
←[36m
  Increment number:   1
  ==========================================================================================
  Loading subpath:    1 |      Load factor | Total =  5.0e-03       Time | Total =  5.0e-03
        Increment:    1 |                  | Incr. =  5.0e-03            | Incr. =  5.0e-03←[0m
←[33m

  Self-consistent scheme iteration:   0
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Young modulus (E): 1.4505e+02  (norm. change: -)
  Poisson ratio (ν): 2.8051e-01  (norm. change: -)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
←[0m
Traceback (most recent call last):
  File "D:\Git\CRATE\benchmarks\run_crate_benchmark.py", line 51, in <module>
    cratepy.crate_simulation(input_file_path,
  File "D:\Git\CRATE/src\cratepy\main.py", line 327, in crate_simulation
    asca.solve_equilibrium_problem(
  File "D:\Git\CRATE\src\cratepy\online\crom\asca.py", line 555, in solve_equilibrium_problem
    type(self)._display_scs_iter_data(ref_material, is_lock_prop_ref,
  File "D:\Git\CRATE\src\cratepy\online\crom\asca.py", line 2666, in _display_scs_iter_data
    info.displayinfo('8', 'init', scs_iter,
  File "D:\Git\CRATE\src\cratepy\ioput\info.py", line 578, in displayinfo
    ioutil.print2(template.format(*info, width=output_width))
  File "D:\Git\CRATE\src\cratepy\ioput\ioutilities.py", line 65, in print2
    print(*objects_esc, file=screen_file)
  File "C:\Users\kingy\Anaconda3\envs\crate\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u03bd' in position 208: character maps to <undefined>

Hello @kingyin3613,

Thank you for reporting this!

It seems that colors and greek letters are not being properly encoded by your OS - Are you running CRATE on Windows?

I believe that I found a similar problem discussed here, where some comments suggest that I must be explicit about the encoding (UTF-8) when running on Windows OS.

I attempted to fix CRATE accordingly, but I am not facing this issue in either Linux or MacOS. Can you please check if the latest version available on CRATE's GitHub repository (master branch) solved the issue?

Thank you!

Yes, I'm using Windows. The encoding error was totally gone with the latest version of CRATE, I think the functionality of this package on my Windows OS has been verified. Although I can still see "←[xx m" in the console (see below), but it is just a minor display issue, you may want to fix this in future versions. Thanks for the quick updates @BernardoFerreira !

←[32m

End phase: ←[37mSolve reduced microscale equilibrium problem (phase duration time = 7.52e+01s)
--------------------------------------------------------------------------------------------←[0m

←[37m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~←[0m
←[33mEnding program execution at: ←[0m20h42m35s (17/Jul/2023)

←[33mProblem analysed: ←[0mexample_1_uniaxial_tension_nc54

←[33mTotal execution time: ←[0m3.04e+02s (~0h5m)

←[33mExecution times:

←[0m    Phase                                                 Duration (s)      %
    ---------------------------------------------------------------------------
    Read input data                                         5.89e-01       0.19
    Compute cluster analysis data matrix                    3.44e+00       1.13
    Perform RVE cluster analysis                            1.38e+01       4.53
    Compute cluster interaction tensors                     9.91e+01      32.56
    Solve reduced microscale equilibrium problem            7.52e+01      24.70
    Accumulated post-processing operations                  1.12e+02      36.81
    ---------------------------------------------------------------------------


                                 ←[32mProgram Completed←[0m

Nice to know that at least the core functionality is now working!

Concerning the colors not displaying properly on Windows, I believe that this has to do with the way that the Python package colorama works in Windows. I found a thread reporting a similar problem, but I currently don't have access to a Windows OS to test some of the simple solutions proposed there.

I'll leave this open and try to fix it as soon as get my hands on a Windows OS!