# How to run python and looking for an example of building an assembly

**URL:** <https://openmc.discourse.group/t/how-to-run-python-and-looking-for-an-example-of-building-an-assembly/387>\
**Category:** User Support\
**Created:** [December 27, 2018, 8:49am UTC](https://openmc.discourse.group/t/how-to-run-python-and-looking-for-an-example-of-building-an-assembly/387 "2018-12-27T08:49:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xuezhong.li4586](https://avatars.discourse-cdn.com/v4/letter/x/c37758/32.png) [@xuezhong.li4586](https://openmc.discourse.group/u/xuezhong.li4586)\
**Post date:** [December 27, 2018, 8:49am UTC](https://openmc.discourse.group/t/how-to-run-python-and-looking-for-an-example-of-building-an-assembly/387/1 "2018-12-27T08:49:55Z")

</div>

hello everyone:

I don’t know how to run openmc with python API.  
In the example files, there are three files: jupter ,python and xml.  
I know how to run openmc in xml files, it is easy.  
but I don’t know how to deal with those in python.  
for example, in /python/ basic/build-xml.py, I have no idea how to run? what should i do?

I am trying to learn how to build an assembly.  
I didn’t find one similar model in examples files.  
Is there any model available for reference?

I have no idea how to build it.

thanks you very much for guiding me

---

<div class="post-metadata">

**Author:** ![khurrum](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@khurrum](https://openmc.discourse.group/u/khurrum)\
**Post date:** [December 27, 2018, 11:21am UTC](https://openmc.discourse.group/t/how-to-run-python-and-looking-for-an-example-of-building-an-assembly/387/2 "2018-12-27T11:21:11Z")

</div>

Hye

In terminal navigate to directory containing .py file for example. Type python build-xml.py. That will build the xml files which you can run easily

---

<div class="post-metadata">

**Author:** ![xuezhong.li4586](https://avatars.discourse-cdn.com/v4/letter/x/c37758/32.png) [@xuezhong.li4586](https://openmc.discourse.group/u/xuezhong.li4586)\
**Post date:** [December 27, 2018, 1:02pm UTC](https://openmc.discourse.group/t/how-to-run-python-and-looking-for-an-example-of-building-an-assembly/387/3 "2018-12-27T13:02:38Z")

</div>

Thanks ,it did works!!

在 2018年12月27日星期四 UTC+8下午7:21:11，Khurrum写道：

---

<div class="post-metadata">

**Author:** ![xuezhong.li4586](https://avatars.discourse-cdn.com/v4/letter/x/c37758/32.png) [@xuezhong.li4586](https://openmc.discourse.group/u/xuezhong.li4586)\
**Post date:** [December 27, 2018, 1:16pm UTC](https://openmc.discourse.group/t/how-to-run-python-and-looking-for-an-example-of-building-an-assembly/387/4 "2018-12-27T13:16:27Z")

</div>

hello everyone:

I have just found some tips in the guidebook:

- " [Docs](https://openmc.readthedocs.io/en/latest/index.html) »
- [Python API](https://openmc.readthedocs.io/en/latest/pythonapi/index.html) »
- `openmc.examples` – Example Models"

---

<div class="post-metadata">

**Author:** ![xuezhong.li4586](https://avatars.discourse-cdn.com/v4/letter/x/c37758/32.png) [@xuezhong.li4586](https://openmc.discourse.group/u/xuezhong.li4586)\
**Post date:** [December 27, 2018, 2:30pm UTC](https://openmc.discourse.group/t/how-to-run-python-and-looking-for-an-example-of-building-an-assembly/387/5 "2018-12-27T14:30:11Z")

</div>

oh yeah, I finally get to know how to use it  
It is easy to implement.  
build an empty .py files and type as the following text:  
import openmc  
aaaa=openmc.examples.pwr\_assembly()  
aaaa.export\_to\_xml()

save and run this .py and we can easily get a 17\*17 PWR assembly model.  
This might be very useful for new learner likes me hahahah

在 2018年12月27日星期四 UTC+8下午9:16:28，xuezhon…@gmail.com写道：
