FileNotFoundError

Dear all,

I get an error after writing the script for simulation and postprocessing.
I’m using the software for the first time so I have for the beginning a few questions and problems, but hopefully, you will bear with me a little.

What is happened:
I have seen the tutorial and have begun to design the patch antenna. So far so good. After saving the file, I went on with scripting. After finishing I get the error “unable to open file “filename.cub5” for reading”. After a few lines of description follows the line:
“FileNotFoundError” [Errno 2] Unable to synchronously open file (unable to open file: name = ‘filename.cub5’, errno = 2, error message = ‘No such file or directory’, flags = 0, 0_flags = 0)

Ok, at first it’s clear what the matter is. But after trying out a few things like saving under another name or in another path, I get lost.
So I switch to the examples where hopefully all works. But … no, it doesn’t work also. I get the same error.
So I’m looking for the error in the Python environment, but what can go wrong here? I use the same in the tutorial (VS Code) and it’s installed on the same computer and the same disk. Also, I use the nullspace compiler.

Does someone have an idea and can help me?

Thankful
Michael

Hi Michael,

Did you run NSPREP and save a cub5 file with the name “filename.cub5”?

Is this cub5 file in the same directory as your Python simulation file?

Did you make a journal file to create your “filename.cub5” file? If so, please copy that journal file content here.

Also, can you please copy your simulation python file content here (the one that has the “filename.cub5” set in it)?

Hey

Yes I saved it in NSPREP as an cub5 file and there are also in the same directory. (Seen at the picture)

I’m sorry but I don’t make a journal file.

Ok, I try to attach it. (Is there an option to add the Data.py as an file and not copy the script?)

Pythencode

import numpy as np

from nsem import *

#config = ‘patch_a_16G’

config = ‘16GHz_patch_antenna’

model = Configuration(f’{config}_wide_sim’) # Configure the simulation name

model.set_cub5_filename(f’{config}.cub5’) # load the corresponding .cub5 file

SEt the basis order function, with 1 being the lowest order (default) and 3 being the highest order

model.set_order(1)

Scale the model to match the unit used in NS Oreo. In NSEM, the unit is meter.

model.set_model_scale(0.001*0.0254) # Conversion from mils to meters

Set the frequency range fpr the simulation in GHz

model.set_frequencies(np.linspace(15, 17, 51))

Save the model configuration

model.save()

Set up the report configuration

report = Report(f’{config}_wide_report’, f’{config}_wide_sim’)

Request Y parameters to be included in the report

report.request_y_parameters()

Define theta an phi step resolution for scanning

step = 2

Define the theta observation range

thObs = np.linspace(0, 180, int(180/ step)) # Generates theta values from 0 to 180 degreees at specified step intervals

Define the phi observation range

phObs = np.linspace(0.360. int(360/step)) # Generates phi values from 0 to 360 degrees at specified step intervals

Request far field data over the grid defined bz theta and phi arrays

report.request_far_fields_grid(thObs, phObs)

Define the desired cut plane for visualization

report.add_plane(‘zx-’+config, -400,400,100,-50,50,100,0,‘zx’)

Request the output to be saved in Paraview format with a specific sample count

report.request_paraview(type=‘xmf’, num_samples=3)

Request surface currents to be included in the report, considering only absolute values

report.request_surface_currents(type=‘NODE’, request_abs=True, request_real = False, request_imag = False)

Save the report configuration

report.save()

Execute the simulation

model.run()

Execute the report generation

report.run()
This text will be hidden

The full terminal answer

Terminal

PS E:\Michael\Nullspace_workspace> & “c:/Program Files/Nullspace EM 2023 R3/Nullspace-Python/python.exe” e:/Michael/Nullspace_workspace/Tests/patch_a_16G_SIM.py
Setting default quadrature values for basis order 1
Unable to open file 16GHz_patch_antenna.cub5 for reading
Traceback (most recent call last):
File “C:\Program Files\Nullspace EM 2023 R3\Nullspace-Python\lib\site-packages\nsem\config.py”, line 667, in __get_materials_in_cub5
h5File = hdf5.openHDF5(self.cub5_filename, ‘r’)
File “C:\Program Files\Nullspace EM 2023 R3\Nullspace-Python\lib\site-packages\nsem\hdf5.py”, line 5, in openHDF5
h5File = h5py.File(filename, mode)
File “C:\Program Files\Nullspace EM 2023 R3\Nullspace-Python\lib\site-packages\h5py_hl\files.py”, line 567, in init
fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
File “C:\Program Files\Nullspace EM 2023 R3\Nullspace-Python\lib\site-packages\h5py_hl\files.py”, line 231, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File “h5py_objects.pyx”, line 54, in h5py._objects.with_phil.wrapper
File “h5py_objects.pyx”, line 55, in h5py._objects.with_phil.wrapper
File “h5py\h5f.pyx”, line 106, in h5py.h5f.open
FileNotFoundError: [Errno 2] Unable to synchronously open file (unable to open file: name = ‘16GHz_patch_antenna.cub5’, errno = 2, error message = ‘No such file or directory’, flags = 0, o_flags = 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “e:\Michael\Nullspace_workspace\Tests\patch_a_16G_SIM.py”, line 19, in
model.save()
File “C:\Program Files\Nullspace EM 2023 R3\Nullspace-Python\lib\site-packages\nsem\config.py”, line 655, in save
self.material_names, self.__cub5_material_library_filename = self.__get_materials_in_cub5()
File “C:\Program Files\Nullspace EM 2023 R3\Nullspace-Python\lib\site-packages\nsem\config.py”, line 669, in __get_materials_in_cub5
raise FileNotFoundError(f’Cannot open {self.cub5_filename} for reading.')
FileNotFoundError: Cannot open 16GHz_patch_antenna.cub5 for reading.
PS E:\Michael\Nullspace_workspace>

Hi Michael,

It is highly recommended to make a journal file of your model. A journal file will allow you to exactly repeat steps you made to create your model. This is useful for many reasons the most important being historical recreation as needed. It also allows you to experiment in-line, and in this case, it will also allow others to easily see what you have done:) If it is possible please consider making your future model(s) w/ a journal file similar in spirit to User Guide examples. All of your GUI commands are in essence syntax commands that can be captured in journal file for playback later as needed.

I will look into how best to transfer your files w/o copying. I will follow up w/ a resolution soon.

I may be able to determine the issue if I had only your cub5 file and simulation file but it would be ideal to have your entire model so that I can try and replicate your problem. If you are able to copy your simulation file and/or a journal file I may be able to help immediately. Regardless I will follow up on the file transfer approach.

Ok, I will do it next time!

If you can send me in private an e-mail address I can send you all data as files.

I figure out that the environment don’t found the folder where all files are included. If I ask for folder content with:

os.listdir

import os

cwd = os.getcwd() # Get the current working directory (cwd)
files = os.listdir(cwd) # Get all the files in that directory
print(“Files in %r: %s” % (cwd, files))

Answer

Files in ‘E:\Michael\Nullspace_workspace’: [‘.idea’, ‘16GHz_patch_antenna_wide_sim.h5’, ‘Folder.PNG’, ‘patch_a_16G_wide_sim.h5’, ‘simulation.h5’, ‘Tests’]

So I have to jump in my folder calling “Tests”, where all my .py scripts are also the .cub5

Michael,

A few tips:

  1. Make sure the working directory is set in NSPrep to the same directory you’re showing us above.
  2. Generate your material library before you create the model so that it’s present at the time you need it within Prep. It looks like you have a material library script, but it doesn’t look like you’ve generate the file yet.
  3. As @mah said, general a journal file for easy replication of the geometry, meshing, and material configuration process.

You can send the files to info@nullspaceinc.com, and we’ll take a look.

Ok, I solved two problems from yesterday, you’re right it was a direction problem. I’ll present later the way of solution and what was wrong for others who are similar to me, not so well in the knowledge of folder and path and so on …

But I still have one more error.
In the sim.py is the comande model.run. The compiler goes in but can’t find the data.
“NSEM failed because the executable could not be found.”
I don’t know which one is searching.
I rebuilt the .cub5 file and saved also a .jou file. I send it to you on the given mail.

path of NSEM

Michael,

Have you been able to go through each of the examples in the User Guide? We strongly encourage that you go through them in order and line-by-line to truly begin gaining a solid understanding of the software. You may also find this series of video tutorials helpful. The user guide is a little more focused on the journal file workflow. The video tutorials are a little more focused on the Prep GUI.

We have modified the forum permissions also such that you should be able to upload your model files.

We are thankful for your effort to begin learning Nullspace and are here to help. Please let me know if you run into any issues with the examples or would like some more help with your model.

Hello Daniel,

Yes, I have done to the

Tutorial

and also to the videos.
At the tutorial, could it be, that there missing the explanation for editing some material property? I get here the error that missing material, I fill it in, with the explanation from the videos.

Furthermore, I’m sending to you an E-Mail at “info@nullspaceinc.com” but haven’t got an answer until now.

Mail

Dear Nullspace Team,

I’m very sorry about wasting your time. I think I took a slightly wrong approach to starting work on Nullspace EM. For me is not only the software new, it’s also the working environment. I have to work on a server without admin rights (we get only one licence for research), which could cause some additional problems.
That’s why I want to propose that you send me a complete working example. Including the .cub5, .jou, material.py, sim.py post.py (and if I need more, them too) data. Please as .zip, because I see the E-Mail environment doesn’t accept sending some .py data.
If you send me this data package, I can be sure, that it works so that I have to search for the mistake in my environment.

Thank you for your support!

Best regards
Michael Kleinschmidt

Hi Michael,

It is my understanding you have resolved all but one issue : you cannot get your sim.py file to execute. Is that correct?

1 Like

Yes, it is correct.
I try it in VS Code and also in Nullspace EM Environment

1 Like

Solved!!

Yes, after a long procedure of try and error, I solve the problems.
And yes, in sum it was a problem of path settings. But not so easy for me to figure it out. In the following, I describe the problems and how I fix them.

Same folder not equal same path

If you save all data in one folder it could be the same path for Windows but not for the software. The path must first be set exactly, it is not enough to open the file from the folder.

So take a look at:

In VS_Code

To be sure, that the scripts to be executed find all needed data, go to VS_Code in the exact folder where you’re working. Only seeing them in your workspace is not enough for execution. With executing of “dir” and “cd” ("cd… ") at the terminal, VSC show you in which direction you are and you can go in or out of the folder. (Set the direction)

For the NS EM enviroment (console) the same applies.

Path NS console

And at least it’s the same for NS Prep where you build up the CAD.

Attention

To set the working direction under “File” → “Set Directory” isn’t enough. You need it to save the data at the right direction but for using the command line, you have to check the direction also.

command line console is also important

As before, “dir” and “cd” are also helpful. But be careful, if you only execute “cd” without adding a path, it changes to the main path and gets out of your direction.

At least, some comments or tips:

nsem load material library

If NS prep doesn’t find any materials, you can also add the path instead of only the filename. Then, you can be sure that it will find it.

What else?

Yes, that isn’t all. I gained some experience with executing the Python simulation and postprocessing files. If I try to execute them from VS_Code it doesn’t work. I get an Error.

The Error

But, if I execute them with the NS EM environment console, it works. The Simulation starts and does what it should be doing. Same for Postprocessing.

At the end, I get the same results as shown in the tutorials. **Happy ** :slight_smile:

What I don’t solve
I tried to find more commands for the command line which could help to fix some problems or make using faster. If you write in NS Prep at the command line “help”, you get a lot of commands, which I don’t know how to use. They also described some commands in the Coreform user guide (Coreform is the basement of NS Prep).
Command Line “Help”
I try to execute the shown examples, I get only errors. What I also see in some pictures like here, is that the command compiler begins with “Cubit>” and not like in NS Prep with “Prep>”. So I’m not sure that NS Prep can use most of the shown commands, because the interpreter doesn’t know them. And most of what is described there you can only use at the original coreform but not in the adapted NS Prep.

This is my current status, which may of course be incorrect. If I solve this over time, I will share it with you.

So far I would like to thank you for your support and hope that I could help others with troubleshooting. If you have any questions, please contact me personally if possible.

Hello @Michael , I wanted to personally thank you for the detailed description of your way of troubleshooting this problem! It will absolutely be helpful to future Nullspace users, as well as our development team, as we work to improve our user experience.

Looking forward to more feedback from you, as you dive deeper intro the simulations.

Thank you,