# Question about forward modeling 1D MT

Hello

I’m new to the SimPEG library and I’m trying to learn how to use it by starting with a 1D MT forward modeling example. I followed the documentation and based my code on the 3D MT forward modeling example (MT: 3D: Forward — SimPEG 0.19.0 documentation) but adapted it to the 1D case.

Here is my code.

``````from discretize import TensorMesh
import matplotlib.pyplot as plt
import numpy as np

from SimPEG.electromagnetics import natural_source as NSEM
from SimPEG.utils.model_builder import create_layers_model
from SimPEG.utils import plot_1d_layer_model
from SimPEG.electromagnetics import frequency_domain as fdem
from SimPEG import maps

# Setting up 1D mesh and conductivity models to forward model data.
# Frequency
nfrec = 12
freqs = np.logspace(-2, 3, nfrec)
half_space = 1000  # resistivity

# Make the grid
thick = 100
n_layer = 50
#tops = np.array([tp for tp in range(0, thick*n_layer, thick)])
hx = [((thick, n_layer-1)),(10000, 1)]  # each layer is 100 m
m1d = TensorMesh([hx], origin='N')

# physical property model (resistivity model)
model = np.ones(n_layer)
model[:10] = 10
model[10:25] = 60
model[25:45] = 200
model[45:50] = 300
model[-1] = half_space

# Define a mapping from model parameters to conductivities
model_mapping = maps.IdentityMap(nP=n_layer)

rx_loc = np.array([0.])  # one point in the surface
for rx_orientation in ["xx", "xy", "yx", "yy"]:
NSEM.Rx.PointNaturalSource(rx_loc, rx_orientation, "real"))
NSEM.Rx.PointNaturalSource(rx_loc, rx_orientation, "imag"))

# Source list
source_list = [NSEM.Src.Planewave(receiver_list, freq) for freq in freqs]
# Survey MT
survey = NSEM.Survey(source_list)

# Setup the problem object
problem = NSEM.Simulation1DPrimarySecondary(
m1d, survey=survey, sigmaMap=model_mapping,
forward_only=True)

# Calculate the data
dpred = problem.dpred(model)

``````

However, I’m getting an error on the final line when I try to compute the forward model:

Traceback (most recent call last):
File “/home/vicente/projects/mtinv/1dtest/test_simpeg.py”, line 65, in
dpred = problem.dpred(model)
File “/home/vicente/miniconda3/envs/1d-deeplearning-MT/lib/python3.10/site-packages/SimPEG/simulation.py”, line 233, in dpred
f = self.fields(m)
File “/home/vicente/miniconda3/envs/1d-deeplearning-MT/lib/python3.10/site-packages/SimPEG/electromagnetics/frequency_domain/simulation.py”, line 116, in fields
u = Ainv * rhs
File “/home/vicente/miniconda3/envs/1d-deeplearning-MT/lib/python3.10/site-packages/pymatsolver/solvers.py”, line 111, in mul
raise TypeError(‘Can only multiply by a numpy array.’)
TypeError: Can only multiply by a numpy array.

How can I fix this error? Any help would be much appreciated.
Thanks,
Vicente