# Add commands to install FEniCSs on Windows on the home website

**URL:** <https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979>\
**Category:** installation\
**Created:** [October 5, 2024, 5:48pm UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979 "2024-10-05T17:48:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![WenyinWei](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wenyinwei/32/939_2.png) [@WenyinWei](https://fenicsproject.discourse.group/u/WenyinWei)\
**Post date:** [October 5, 2024, 5:48pm UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979/1 "2024-10-05T17:48:11Z")

</div>

[https://fenicsproject.org/download/](https://fenicsproject.org/download/)

Please help add commands to install on Windows, otherwise, people would try those commands for MacOS which does not work for Windows.

According to Github README, the latest commands to install on Windows are:

```auto
conda create -n fenicsx-env
conda activate fenicsx-env
conda install -c minrk/label/fenics-windows -c conda-forge fenics-dolfinx=0.9.0.dev

```

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [October 5, 2024, 9:38pm UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979/2 "2024-10-05T21:38:32Z")

</div>

Once the 0.9 release is out, where windows is supported (without PETSc), the instructions will be added to the webpage.

---

<div class="post-metadata">

**Author:** ![pierremrtt](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pierremrtt](https://fenicsproject.discourse.group/u/pierremrtt)\
**Post date:** [October 8, 2024, 3:12pm UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979/3 "2024-10-08T15:12:53Z")

</div>

Hi community !

I see the availability of FEniCSx on windows machine is very close to be completely accomplished !  
In few weeks, at the ASSA autumn school in Eindhoven, some professors (including myself) from KTH Sweden will present FEniCSx implementations for very simple case of FE method applications. And next, there is the desire to bring FEniCSx in our lectures and tutorial at KTH university. So I’m in charge of building a procedure for the student to download FEniCSx according to their system (MacOS, Linux, Windows…). This whole procedure might involve non FEniCSx things like Docker for instance. I think the most general procedure will involve conda installation, so my question is the following : Do you think 0.9 version will be released before the end of October ?

All the best,  
Pierre.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [October 8, 2024, 3:58pm UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979/4 "2024-10-08T15:58:31Z")

</div>

Yes, I do believe so.  
Note that Dolfinx on windows will not have PETSC support, so for teaching you would rely on scipy for solving the problems in Python (and thus mainly serial problems).

Everything in dolfinx itself will work in parallel, but there is a lack of MPI compatible solvers on windows…

---

<div class="post-metadata">

**Author:** ![pierremrtt](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pierremrtt](https://fenicsproject.discourse.group/u/pierremrtt)\
**Post date:** [October 8, 2024, 8:05pm UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979/5 "2024-10-08T20:05:26Z")

</div>

That’s what I understood yup… But as it will be very easy case, I think it might be enough. Thanks for the quick reply!

Pierre.

---

<div class="post-metadata">

**Author:** ![francesco-ballarin](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@francesco-ballarin](https://fenicsproject.discourse.group/u/francesco-ballarin)\
**Post date:** [October 9, 2024, 5:27am UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979/6 "2024-10-09T05:27:15Z")

</div>

> [@pierremrtt](#):
>
> In few weeks, at the ASSA autumn school in Eindhoven, some professors (including myself) from KTH Sweden will present FEniCSx implementations for very simple case of FE method applications

Shameless off-topic self-advertising: for my teaching needs, and for the teaching needs of several colleagues, I use [https://fem-on-colab.github.io/](https://fem-on-colab.github.io/) . Using Colab is definitely not the perfect solution, but for us is a good compromise, especially for its ease of usability/installation.

---

<div class="post-metadata">

**Author:** ![pierremrtt](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pierremrtt](https://fenicsproject.discourse.group/u/pierremrtt)\
**Post date:** [October 9, 2024, 9:51am UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979/7 "2024-10-09T09:51:32Z")

</div>

I think this is exactly what I need, thank you very much. However, I’m facing a simple problem. That is not realted to this topic anymore, I can create a new topic on the discourse and copy paste the following :

I’ve implemented a simple 1D helmholtz problem with the fem on collab strategy, with boundary condition. Even if I’ve installed the Dolfinx version from the complex branch, I have a message error saying :

```auto
---------------------------------------------------------------------------
ArityMismatch Traceback (most recent call last)
<ipython-input-6-9c15c347e209> in <cell line: 46>()
     44 
     45 # Solving the linear system
---> 46 problem = LinearProblem(a, L, petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
     47 p_solution = problem.solve()
     48 

14 frames
/usr/local/lib/python3.10/dist-packages/ufl/algorithms/check_arities.py in check_integrand_arity(expr, arguments, complex_mode)
    203 for arg, conj in arg_tuples:
    204 if arg.number() == 0 and not conj:
--> 205 raise ArityMismatch("Failure to conjugate test function in complex Form")
    206 elif arg.number() > 0 and conj:
    207 raise ArityMismatch(f"Argument {arg} is spuriously conjugated in complex Form")

ArityMismatch: Failure to conjugate test function in complex Form

```

Here it’s my code, I don’t think my FE code is the problem but more probably from installation. So I give here the first notebook collab cell that might donwload the complex dolfinx branch, and then my FE code:  
[1]

```auto
import os
arch = os.getenv("ARGS", "complex")

try:
    import google.colab # noqa: F401
except ImportError:
    import ufl
    import dolfinx
else:
    try:
        import ufl
        import dolfinx
    except ImportError:
        if arch != "complex":
            !wget "https://fem-on-colab.github.io/releases/fenicsx-install-real.sh" -O "/tmp/fenicsx-install.sh" && bash "/tmp/fenicsx-install.sh"
        else:
            !wget "https://fem-on-colab.github.io/releases/fenicsx-install-complex.sh" -O "/tmp/fenicsx-install.sh" && bash "/tmp/fenicsx-install.sh"
        import ufl
        import dolfinx

```

[2]

```auto
import numpy as np
import dolfinx
from mpi4py import MPI
from petsc4py import PETSc
from ufl import TrialFunction, TestFunction, dx, grad, inner, div, ds, as_vector, Measure
from basix.ufl import element
from dolfinx.fem import Function, FunctionSpace, assemble_scalar, form, functionspace
from dolfinx.fem.petsc import LinearProblem
from dolfinx.mesh import create_interval
from dolfinx.io import XDMFFile

# Problem parameters
Lf = 1.0 # Domain length (1 meter)
rho_0 = 1.21 # Volumic masse of air (kg/m^3)
c = 343.0 # Speed of sound in the air (m/s)
omega = 2 * np.pi * 1000 # Angular frequency 
k = omega / c # Wave number
Z_n = rho_0 * c # Acoustic impedance

# 1D mesh
mesh = create_interval(MPI.COMM_WORLD, 100, [0, Lf])

# Space function
Ve = element("Lagrange", mesh.basix_cell(), 2)
V = functionspace(mesh, ("Lagrange", 2))

# Test and Trial functions
p = TrialFunction(V)
v = TestFunction(V)

# Variational formulation
a = inner(grad(p), grad(v)) * dx - k**2 * inner(p, v) * dx

# Source term
f = Function(V)
L = inner(f, v) * dx

# Boundary condition : Impedance x = Lf Neuman condition x = 0
ds_boundary = Measure("ds", domain=mesh, subdomain_data=None)
n = as_vector((1,))  

a += (1j * omega * rho_0 / Z_n) * p * v * ds_boundary(1)  
L += omega**2 * rho_0 * 1.0 * v * ds_boundary(0)  

# Solving the linear system
problem = LinearProblem(a, L, petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
p_solution = problem.solve()

# Save + Visualization
with XDMFFile(MPI.COMM_WORLD, "solution_helmholtz.xdmf", "w") as xdmf:
    xdmf.write_mesh(mesh)
    xdmf.write_function(p_solution)

try:
    import pyvista
    from dolfinx.plot import create_vtk_mesh
    topology, cell_types, x = create_vtk_mesh(mesh)
    grid = pyvista.UnstructuredGrid(topology, cell_types, x)
    grid["Solution"] = p_solution.x.array.real
    plotter = pyvista.Plotter()
    plotter.add_mesh(grid, show_edges=True)
    plotter.show()
except ImportError:
    pass

```

Thanks a lot,  
Pierre

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [October 9, 2024, 10:08am UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979/8 "2024-10-09T10:08:25Z")

</div>

> [@pierremrtt](#):
>
> ```auto
> a += (1j * omega * rho_0 / Z_n) * p * v * ds_boundary(1)  
> L += omega**2 * rho_0 * 1.0 * v * ds_boundary(0)  
> 
> ```

When working in complex mode, one has to pay particular attention to the inner products, as UFL expects that the test function is always conjugated (this happens automatically when using inner, as `inner(a, b)=ufl.dot(a, ufl.conj(b))`.

See for instance: [The Poisson problem with complex numbers — FEniCSx tutorial](https://jsdokken.com/dolfinx-tutorial/chapter1/complex_mode.html)

---

<div class="post-metadata">

**Author:** ![pierremrtt](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pierremrtt](https://fenicsproject.discourse.group/u/pierremrtt)\
**Post date:** [October 9, 2024, 10:19am UTC](https://fenicsproject.discourse.group/t/add-commands-to-install-fenicss-on-windows-on-the-home-website/15979/9 "2024-10-09T10:19:35Z")

</div>

You’re right I’ve been a bit fast and didn’t use the inner product in the boundary term, here it is:

```auto
a += inner((1j * omega * rho_0 / Z_n) * p, v) * ds_boundary(1)  
L += inner(omega**2 * rho_0 * 1.0, v) * ds_boundary(0) 

```

My code then presents new errors, but I’ll work on it on my own and open a new topic if it’s needed.

Thanks a lot for the help, once again
